diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-11-11 15:53:00 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-18 13:59:33 +0100 |
commit | c5f3c61469517a4ac00e4da01fe0bab9188c1488 (patch) | |
tree | f5003575925ea3f88e469380f29454d1f1fbca49 | |
parent | 4fd2c8fe1d679302391218aec03aa309afd38c55 (diff) |
Port from container::count() and length() to size() - V5
This is the same semantic patch (qt-port-to-std-compatible-api V5
with config Scope: 'Container') as in dev. I've re-ran it in 6.4 to
avoid cherry-pick conflicts.
Like in dev, added two NOLINTNEXTLINEs in tst_qbitarray and
tst_qcontiguouscache, to avoid porting calls that explicitly test
count().
Change-Id: I9621dee5ed328b47e78919a34c307105e4311903
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
632 files changed, 6478 insertions, 6475 deletions
diff --git a/qmake/cachekeys.h b/qmake/cachekeys.h index ffe40fb783..d364912ee5 100644 --- a/qmake/cachekeys.h +++ b/qmake/cachekeys.h @@ -65,7 +65,7 @@ struct FileInfoCacheKey return hash; } inline bool isRelativePath(const QString &file) { - int length = file.length(); + int length = file.size(); if (!length) return true; diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index efc7528c56..942ccc392f 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -87,7 +87,7 @@ ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) for(int pb_subdir = 0; pb_subdir < pb_subdirs.size(); ++pb_subdir) { ProjectBuilderSubDirs *pb = pb_subdirs[pb_subdir]; const ProStringList &subdirs = pb->project->values("SUBDIRS"); - for(int subdir = 0; subdir < subdirs.count(); subdir++) { + for(int subdir = 0; subdir < subdirs.size(); subdir++) { ProString tmpk = subdirs[subdir]; const ProKey fkey(tmpk + ".file"); if (!pb->project->isEmpty(fkey)) { @@ -329,7 +329,7 @@ ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) t << "\t\t\tprojectReferences = (\n"; { const ProStringList &qmake_subdirs = project->values("QMAKE_PBX_SUBDIRS"); - for(int i = 0; i < qmake_subdirs.count(); i++) { + for(int i = 0; i < qmake_subdirs.size(); i++) { const ProString &subdir = qmake_subdirs[i]; t << "\t\t\t\t{\n" << "\t\t\t\t\t" << writeSettings("ProductGroup", keyFor(subdir + "_PRODUCTGROUP")) << ";\n" @@ -524,14 +524,14 @@ bool ProjectBuilderMakefileGenerator::replaceLibrarySuffix(const QString &lib_fi warn_msg(WarnLogic, "Failed to find expected suffix '%s' for library '%s'.", qPrintable(librarySuffix), qPrintable(library)); } else { - library.replace(pos, librarySuffix.length(), suffixSetting); + library.replace(pos, librarySuffix.size(), suffixSetting); if (name.endsWith(librarySuffix)) - name.chop(librarySuffix.length()); + name.chop(librarySuffix.size()); } } else { int pos = library.lastIndexOf(name); if (pos != -1) - library.insert(pos + name.length(), suffixSetting); + library.insert(pos + name.size(), suffixSetting); } } } @@ -658,7 +658,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) const QStringList &files = fileFixify(sources.at(source).files(project), FileFixifyFromOutdir | FileFixifyAbsolute); - for(int f = 0; f < files.count(); ++f) { + for(int f = 0; f < files.size(); ++f) { QString file = files[f]; if(!sources.at(source).compilerName().isNull() && !verifyExtraCompiler(sources.at(source).compilerName(), file)) @@ -873,7 +873,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr }; for (int i = 0; libs[i]; i++) { tmp = project->values(libs[i]); - for(int x = 0; x < tmp.count();) { + for(int x = 0; x < tmp.size();) { bool libSuffixReplaced = false; bool remove = false; QString library, name; @@ -912,7 +912,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) if(opt.size() > 2) { r = opt.mid(2).toQString(); } else { - if(x == tmp.count()-1) + if(x == tmp.size()-1) break; r = tmp[++x].toQString(); } @@ -921,12 +921,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) frameworkdirs.append(r); } } else if(opt == "-framework") { - if(x == tmp.count()-1) + if(x == tmp.size()-1) break; const ProString &framework = tmp[x+1]; ProStringList fdirs = frameworkdirs; fdirs << "/System/Library/Frameworks/" << "/Library/Frameworks/"; - for(int fdir = 0; fdir < fdirs.count(); fdir++) { + for(int fdir = 0; fdir < fdirs.size(); fdir++) { if(exists(fdirs[fdir] + QDir::separator() + framework + ".framework")) { remove = true; library = fdirs[fdir] + Option::dir_sep + framework + ".framework"; @@ -955,7 +955,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) const int slsh = library.lastIndexOf(Option::dir_sep); if(name.isEmpty()) { if(slsh != -1) - name = library.right(library.length() - slsh - 1); + name = library.right(library.size() - slsh - 1); } if(slsh != -1) { const QString path = QFileInfo(library.left(slsh)).absoluteFilePath(); @@ -1008,12 +1008,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) mkt << "SUBLIBS= "; // ### This is missing the parametrization found in unixmake2.cpp tmp = project->values("SUBLIBS"); - for(int i = 0; i < tmp.count(); i++) + for(int i = 0; i < tmp.size(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") << ' '; t << Qt::endl << Qt::endl; mkt << "sublibs: $(SUBLIBS)\n\n"; tmp = project->values("SUBLIBS"); - for(int i = 0; i < tmp.count(); i++) + for(int i = 0; i < tmp.size(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") + ":\n\t" << var(ProKey("MAKELIB" + tmp[i])) << Qt::endl << Qt::endl; mkt.flush(); @@ -1148,7 +1148,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) //all bundle data const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA"); - for(int i = 0; i < bundle_data.count(); i++) { + for(int i = 0; i < bundle_data.size(); i++) { ProStringList bundle_files; ProString path = project->first(ProKey(bundle_data[i] + ".path")); const bool isEmbeddedFramework = ((!osx && path == QLatin1String("Frameworks")) @@ -1158,7 +1158,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) //all files const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files")); - for(int file = 0; file < files.count(); file++) { + for(int file = 0; file < files.size(); file++) { QString fn = fileFixify(files[file].toQString(), FileFixifyAbsolute); QString name = fn.split(Option::dir_sep).back(); QString file_ref_key = keyFor("QMAKE_PBX_BUNDLE_DATA_FILE_REF." + bundle_data[i] + "-" + fn); @@ -1684,7 +1684,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) t << "\t\t\t\t" << writeSettings("CODE_SIGN_IDENTITY", project->first("QMAKE_XCODE_CODE_SIGN_IDENTITY")) << ";\n"; tmp = project->values("QMAKE_PBX_VARS"); - for (int i = 0; i < tmp.count(); i++) { + for (int i = 0; i < tmp.size(); i++) { QString var = tmp[i].toQString(), val = QString::fromLocal8Bit(qgetenv(var.toLatin1().constData())); if (val.isEmpty() && var == "TB") val = "/usr/bin/"; @@ -1888,7 +1888,7 @@ ProStringList ProjectBuilderMakefileGenerator::fixListForOutput(const ProStringList &l) { ProStringList ret; - for(int i = 0; i < l.count(); i++) + for(int i = 0; i < l.size(); i++) ret += fixForOutput(l[i].toQString()); return ret; } @@ -1970,7 +1970,7 @@ ProjectBuilderMakefileGenerator::pbxbuild() static QString quotedStringLiteral(const QString &value) { QString result; - const int len = value.length(); + const int len = value.size(); result.reserve(int(len * 1.1) + 2); result += QLatin1Char('"'); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 4c21ef8202..3cf3493030 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -38,7 +38,7 @@ using namespace QMakeInternal; bool MakefileGenerator::canExecute(const QStringList &cmdline, int *a) const { int argv0 = -1; - for(int i = 0; i < cmdline.count(); ++i) { + for(int i = 0; i < cmdline.size(); ++i) { if(!cmdline.at(i).contains('=')) { argv0 = i; break; @@ -112,7 +112,7 @@ MakefileGenerator::initOutPaths() if(!fi.makeAbsolute()) { QString cache_r = fi.path(), pwd = Option::output_dir; if(pwd.startsWith(cache_r) && !pwd.startsWith(root)) { - pwd = root + pwd.mid(cache_r.length()); + pwd = root + pwd.mid(cache_r.size()); if(exists(pwd)) v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", ProStringList(pwd)); } @@ -237,7 +237,7 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString { ProStringList vpath; const ProValueMap &v = project->variables(); - for(int val_it = 0; val_it < l.count(); ) { + for(int val_it = 0; val_it < l.size(); ) { bool remove_file = false; ProString &val = l[val_it]; if(!val.isEmpty()) { @@ -287,7 +287,7 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString real_dir = dir; if(!(flags & VPATH_NoFixify)) real_dir = fileFixify(real_dir, FileFixifyBackwards) + '/'; - regex.remove(0, dir.length()); + regex.remove(0, dir.size()); } if(real_dir.isEmpty() || exists(real_dir)) { QStringList files = QDir(real_dir).entryList(QStringList(regex), @@ -303,7 +303,7 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString } else { l.removeAt(val_it); QString a; - for(int i = (int)files.count()-1; i >= 0; i--) { + for(int i = (int)files.size()-1; i >= 0; i--) { a = real_dir + files[i]; if(!(flags & VPATH_NoFixify)) a = fileFixify(a); @@ -467,12 +467,12 @@ MakefileGenerator::init() continue; } const ProStringList &tinn = v[innkey], &toutn = v[outnkey]; - if (tinn.length() != 1) { + if (tinn.size() != 1) { warn_msg(WarnLogic, "Substitute '%s.input' does not have exactly one value", sub.toLatin1().constData()); continue; } - if (toutn.length() != 1) { + if (toutn.size() != 1) { warn_msg(WarnLogic, "Substitute '%s.output' does not have exactly one value", sub.toLatin1().constData()); continue; @@ -490,7 +490,7 @@ MakefileGenerator::init() inn.toLatin1().constData()); continue; } - outn = fileFixify(inn.left(inn.length() - 3), FileFixifyBackwards); + outn = fileFixify(inn.left(inn.size() - 3), FileFixifyBackwards); } const ProKey confign(sub + ".CONFIG"); @@ -511,7 +511,7 @@ MakefileGenerator::init() QString line = QString::fromLatin1(in.readLine()); if (line.startsWith("!!IF ")) { if (state.isEmpty() || state.top() == IN_CONDITION) { - QString test = line.mid(5, line.length()-(5+1)); + QString test = line.mid(5, line.size()-(5+1)); if (project->test(test, inn, count)) state.push(IN_CONDITION); else @@ -524,7 +524,7 @@ MakefileGenerator::init() warn_msg(WarnLogic, "(%s:%d): Unexpected else condition", in.fileName().toLatin1().constData(), count); } else if (state.top() == PENDING_CONDITION) { - QString test = line.mid(7, line.length()-(7+1)); + QString test = line.mid(7, line.size()-(7+1)); if (project->test(test, inn, count)) { state.pop(); state.push(IN_CONDITION); @@ -633,12 +633,12 @@ MakefileGenerator::init() } { //do the path fixifying ProStringList paths; - for(x = 0; x < compilers.count(); ++x) { + for(x = 0; x < compilers.size(); ++x) { if(!paths.contains(compilers.at(x).variable_in)) paths << compilers.at(x).variable_in; } paths << "INCLUDEPATH" << "QMAKE_INTERNAL_INCLUDED_FILES" << "PRECOMPILED_HEADER"; - for(int y = 0; y < paths.count(); y++) { + for(int y = 0; y < paths.size(); y++) { ProStringList &l = v[paths[y].toKey()]; for (ProStringList::Iterator it = l.begin(); it != l.end(); ++it) { if((*it).isEmpty()) @@ -652,7 +652,7 @@ MakefileGenerator::init() if(noIO() || !doDepends() || project->isActiveConfig("GNUmake")) QMakeSourceFileInfo::setDependencyMode(QMakeSourceFileInfo::NonRecursive); - for(x = 0; x < compilers.count(); ++x) + for(x = 0; x < compilers.size(); ++x) initCompiler(compilers.at(x)); //merge actual compiler outputs into their variable_out. This is done last so that @@ -763,7 +763,7 @@ MakefileGenerator::init() incDirs.join(QString(" :: ")).toLatin1().constData()); //add to dependency engine - for(x = 0; x < compilers.count(); ++x) { + for(x = 0; x < compilers.size(); ++x) { const MakefileGenerator::Compiler &comp = compilers.at(x); if(!(comp.flags & Compiler::CompilerNoCheckDeps)) { const ProKey ikey(comp.variable_in); @@ -819,14 +819,14 @@ MakefileGenerator::init() QString dir, regex = Option::normalizePath(dep); if (regex.lastIndexOf('/') != -1) { dir = regex.left(regex.lastIndexOf('/') + 1); - regex.remove(0, dir.length()); + regex.remove(0, dir.size()); } QStringList files = QDir(dir).entryList(QStringList(regex)); if(files.isEmpty()) { warn_msg(WarnLogic, "Dependency for [%s]: Not found %s", (*file_it).toLatin1().constData(), dep.toLatin1().constData()); } else { - for(int i = 0; i < files.count(); i++) + for(int i = 0; i < files.size(); i++) out_deps.append(dir + files[i]); } } @@ -1172,7 +1172,7 @@ QString MakefileGenerator::filePrefixRoot(const QString &root, const QString &path) { QString ret(path); - if(path.length() > 2 && path[1] == ':') //c:\foo + if(path.size() > 2 && path[1] == ':') //c:\foo ret.insert(2, root); else ret.prepend(root); @@ -1248,14 +1248,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) qPrintable(wild), qPrintable((*it).toQString()), qPrintable(base_path)); } else { - QString dir_sfx = dirstr.mid(base_path.length()); + QString dir_sfx = dirstr.mid(base_path.size()); dst_dir += dir_sfx; if (!dir_sfx.isEmpty() && !made_dirs.contains(dir_sfx)) { made_dirs.insert(dir_sfx); QString tmp_dst = fileFixify(dst_dir, FileFixifyAbsolute, false); tmp_dst.chop(1); inst << mkdir_p_asstring(filePrefixRoot(root, tmp_dst)); - for (int i = dst.length(); i < dst_dir.length(); i++) { + for (int i = dst.size(); i < dst_dir.size(); i++) { if (dst_dir.at(i) == Option::dir_sep) { QString subd = dst_dir.left(i); if (!removed_dirs.contains(subd)) { @@ -1315,7 +1315,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) inst << cmd; uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false)))); } - for(int x = 0; x < files.count(); x++) { + for(int x = 0; x < files.size(); x++) { QString file = files[x]; uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false)))); QFileInfo fi(fileInfo(dirstr + file)); @@ -1615,7 +1615,7 @@ MakefileGenerator::replaceExtraCompilerVariables( QFileInfo fi(fileInfo(Option::normalizePath(in.at(i)))); QString ext; // Ensure complementarity with QMAKE_FILE_BASE - int baseLen = fi.completeBaseName().length(); + int baseLen = fi.completeBaseName().size(); if(baseLen == 0) ext = fi.fileName(); else @@ -1681,7 +1681,7 @@ MakefileGenerator::replaceExtraCompilerVariables( fullVal = val.join(' '); } ret.replace(match.capturedStart(), match.capturedLength(), fullVal); - rep += fullVal.length(); + rep += fullVal.size(); } else { rep = match.capturedEnd(); } @@ -1882,7 +1882,7 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom return; QDir outDir(Option::output_dir); QStringList dep_cmd_deps = splitDeps(indeps, dep_lines); - for (int i = 0; i < dep_cmd_deps.count(); ++i) { + for (int i = 0; i < dep_cmd_deps.size(); ++i) { QString &file = dep_cmd_deps[i]; const QString absFile = outDir.absoluteFilePath(file); if (absFile == file) { @@ -1997,8 +1997,8 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QString files; const int commandlineLimit = 2047; // NT limit, expanded for (const QString &file : qAsConst(dels)) { - if(del_statement.length() + files.length() + - qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) { + if(del_statement.size() + files.size() + + qMax(fixEnvVariables(file).size(), file.size()) > commandlineLimit) { cleans.append(files); files.clear(); } @@ -2381,7 +2381,7 @@ MakefileGenerator::findSubDirsSubTargets() const if(new_slsh != -1) basename = basename.mid(new_slsh+1); if(st->profile != basename + Option::pro_ext) - st->makefile += "." + st->profile.left(st->profile.length() - Option::pro_ext.length()); + st->makefile += "." + st->profile.left(st->profile.size() - Option::pro_ext.size()); } } const ProKey dkey(fixedSubdir + ".depends"); @@ -2520,7 +2520,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT if(!out_directory.isEmpty() && !out_directory.endsWith(Option::dir_sep)) out_directory += Option::dir_sep; if(!abs_source_path.isEmpty() && out_directory.startsWith(abs_source_path)) - out_directory = Option::output_dir + out_directory.mid(abs_source_path.length()); + out_directory = Option::output_dir + out_directory.mid(abs_source_path.size()); QString out_directory_cdin = out_directory.isEmpty() ? QString("\n\t") : "\n\tcd " + escapeFilePath(out_directory) + " && "; @@ -2533,7 +2533,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT out = subtarget->makefile; in = escapeFilePath(fileFixify(in_directory + subtarget->profile, FileFixifyAbsolute)); if(out.startsWith(in_directory)) - out = out.mid(in_directory.length()); + out = out.mid(in_directory.size()); out = escapeFilePath(out); t << subtarget->target << "-qmake_all: "; if (flags & SubTargetOrdered) { @@ -2698,7 +2698,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT if(!out_directory.isEmpty() && !out_directory.endsWith(Option::dir_sep)) out_directory += Option::dir_sep; if(!abs_source_path.isEmpty() && out_directory.startsWith(abs_source_path)) - out_directory = Option::output_dir + out_directory.mid(abs_source_path.length()); + out_directory = Option::output_dir + out_directory.mid(abs_source_path.size()); if(!recurse.contains(subtarget->name)) continue; @@ -2713,7 +2713,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT out = subtarget->makefile; in = escapeFilePath(fileFixify(in_directory + subtarget->profile, FileFixifyAbsolute)); if (out.startsWith(in_directory)) - out = out.mid(in_directory.length()); + out = out.mid(in_directory.size()); out = escapeFilePath(out); } @@ -2849,7 +2849,7 @@ MakefileGenerator::fixLibFlags(const ProKey &var) const ProStringList &in = project->values(var); ProStringList ret; - ret.reserve(in.length()); + ret.reserve(in.size()); for (const ProString &v : in) ret << fixLibFlag(v); return ret; @@ -3015,7 +3015,7 @@ MakefileGenerator::fileFixify(const QString &file, FileFixifyTypes fix, bool can if(ret == match_dir) { ret = ""; } else if(ret.startsWith(match_dir + Option::dir_sep)) { - ret = ret.mid(match_dir.length() + Option::dir_sep.length()); + ret = ret.mid(match_dir.size() + Option::dir_sep.size()); } else { //figure out the depth int depth = 4; @@ -3037,7 +3037,7 @@ MakefileGenerator::fileFixify(const QString &file, FileFixifyTypes fix, bool can break; if(ret.startsWith(match_dir + Option::dir_sep)) { //concat - int remlen = ret.length() - (match_dir.length() + 1); + int remlen = ret.size() - (match_dir.size() + 1); if(remlen < 0) remlen = 0; ret = ret.right(remlen); @@ -3111,12 +3111,12 @@ MakefileGenerator::findFileForDep(const QMakeLocalFileName &dep, const QMakeLoca QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths(); depdirs.prepend(fileInfo(file.real()).absoluteDir().path()); QString pwd = qmake_getpwd(); - if(pwd.at(pwd.length()-1) != '/') + if(pwd.at(pwd.size()-1) != '/') pwd += '/'; - for(int i = 0; i < depdirs.count(); i++) { + for(int i = 0; i < depdirs.size(); i++) { QString dir = depdirs.at(i).real(); if(!QDir::isRelativePath(dir) && dir.startsWith(pwd)) - dir = dir.mid(pwd.length()); + dir = dir.mid(pwd.size()); if(QDir::isRelativePath(dir)) { if(!dir.endsWith(Option::dir_sep)) dir += Option::dir_sep; @@ -3232,7 +3232,7 @@ MakefileGenerator::pkgConfigFileName(bool fixify) ret = project->first("TARGET").toQString(); int slsh = ret.lastIndexOf(Option::dir_sep); if (slsh != -1) - ret = ret.right(ret.length() - slsh - 1); + ret = ret.right(ret.size() - slsh - 1); if (ret.startsWith("lib")) ret = ret.mid(3); int dot = ret.indexOf('.'); @@ -3537,7 +3537,7 @@ MakefileGenerator::LinkerResponseFileInfo MakefileGenerator::maybeCreateLinkerRe // When using QMAKE_LINK_OBJECT_MAX, the number of object files (regardless of their path // length) decides whether to use a response file. This is far from being a useful // heuristic but let's keep this behavior for backwards compatibility. - if (linkerInputs.count() < threshold) + if (linkerInputs.size() < threshold) return {}; } else { // When using QMAKE_REPONSEFILE_THRESHOLD, try to determine the command line length of the diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 0646d232ce..959633d606 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -164,7 +164,7 @@ void QMakeSourceFileInfo::setDependencyPaths(const QList<QMakeLocalFileName> &l) { // Ensure that depdirs does not contain the same paths several times, to minimize the stats QList<QMakeLocalFileName> ll; - for (int i = 0; i < l.count(); ++i) { + for (int i = 0; i < l.size(); ++i) { if (!ll.contains(l.at(i))) ll.append(l.at(i)); } diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 9616e560b5..c9235509f2 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -52,7 +52,7 @@ public: void BuildsMetaMakefileGenerator::clearBuilds() { - for(int i = 0; i < makefiles.count(); i++) { + for(int i = 0; i < makefiles.size(); i++) { Build *build = makefiles[i]; if(QMakeProject *p = build->makefile->projectFile()) { if(p != project) @@ -73,12 +73,12 @@ BuildsMetaMakefileGenerator::init() const ProStringList &builds = project->values("BUILDS"); bool use_single_build = builds.isEmpty(); - if(builds.count() > 1 && Option::output.fileName() == "-") { + if(builds.size() > 1 && Option::output.fileName() == "-") { use_single_build = true; warn_msg(WarnLogic, "Cannot direct to stdout when using multiple BUILDS."); } if(!use_single_build) { - for(int i = 0; i < builds.count(); i++) { + for(int i = 0; i < builds.size(); i++) { ProString build = builds[i]; MakefileGenerator *makefile = processBuild(build); if(!makefile) @@ -91,7 +91,7 @@ BuildsMetaMakefileGenerator::init() } else { Build *b = new Build; b->name = name; - if(builds.count() != 1) + if(builds.size() != 1) b->build = build.toQString(); b->makefile = makefile; makefiles += b; @@ -126,7 +126,7 @@ BuildsMetaMakefileGenerator::write() bool ret = true; const QString &output_name = Option::output.fileName(); - for(int i = 0; ret && i < makefiles.count(); i++) { + for(int i = 0; ret && i < makefiles.size(); i++) { Option::output.setFileName(output_name); Build *build = makefiles[i]; @@ -223,7 +223,7 @@ void BuildsMetaMakefileGenerator::accumulateVariableFromBuilds(const ProKey &nam void BuildsMetaMakefileGenerator::checkForConflictingTargets() const { - if (makefiles.count() < 3) { + if (makefiles.size() < 3) { // Checking for conflicts only makes sense if we have more than one BUILD, // and the last entry in makefiles is the "glue" Build. return; @@ -234,7 +234,7 @@ void BuildsMetaMakefileGenerator::checkForConflictingTargets() const } using TargetInfo = std::pair<Build *, ProString>; QList<TargetInfo> targets; - const int last = makefiles.count() - 1; + const int last = makefiles.size() - 1; targets.resize(last); for (int i = 0; i < last; ++i) { Build *b = makefiles.at(i); @@ -324,7 +324,7 @@ SubdirsMetaMakefileGenerator::init() if(!subdir.isRelative()) { //we can try to make it relative QString subdir_path = subdir.filePath(); if(subdir_path.startsWith(thispwd)) - subdir = QFileInfo(subdir_path.mid(thispwd.length())); + subdir = QFileInfo(subdir_path.mid(thispwd.size())); } //handle sub project @@ -391,12 +391,12 @@ SubdirsMetaMakefileGenerator::write() const QString &pwd = qmake_getpwd(); const QString &output_dir = Option::output_dir; const QString &output_name = Option::output.fileName(); - for(int i = 0; ret && i < subs.count(); i++) { + for(int i = 0; ret && i < subs.size(); i++) { const Subdir *sub = subs.at(i); qmake_setpwd(sub->input_dir); Option::output_dir = QFileInfo(sub->output_dir).absoluteFilePath(); Option::output.setFileName(sub->output_file); - if(i != subs.count()-1) { + if(i != subs.size()-1) { for (int ind = 0; ind < sub->indent; ++ind) printf(" "); printf("Writing %s\n", QDir::cleanPath(Option::output_dir+"/"+ @@ -414,7 +414,7 @@ SubdirsMetaMakefileGenerator::write() SubdirsMetaMakefileGenerator::~SubdirsMetaMakefileGenerator() { - for(int i = 0; i < subs.count(); i++) + for(int i = 0; i < subs.size(); i++) delete subs[i]; subs.clear(); } diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index 730e16fdaf..2167f6b72a 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -54,7 +54,7 @@ ProjectGenerator::init() dirs.prepend(qmake_getpwd()); } - for(int i = 0; i < dirs.count(); ++i) { + for(int i = 0; i < dirs.size(); ++i) { QString dir, regex, pd = dirs.at(i); bool add_depend = false; if(exists(pd)) { @@ -66,7 +66,7 @@ ProjectGenerator::init() dir += Option::dir_sep; if (Option::recursive) { QStringList files = QDir(dir).entryList(QDir::Files); - for (int i = 0; i < files.count(); i++) + for (int i = 0; i < files.size(); i++) dirs.append(dir + files[i] + QDir::separator() + builtin_regex); } regex = builtin_regex; @@ -87,16 +87,16 @@ ProjectGenerator::init() int s = regex.lastIndexOf(Option::dir_sep); if(s != -1) { dir = regex.left(s+1); - regex = regex.right(regex.length() - (s+1)); + regex = regex.right(regex.size() - (s+1)); } const QDir d(dir); if (Option::recursive) { QStringList entries = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - for (int i = 0; i < entries.count(); i++) + for (int i = 0; i < entries.size(); i++) dirs.append(dir + entries[i] + QDir::separator() + regex); } QStringList files = d.entryList(QDir::nameFiltersFromString(regex)); - for(int i = 0; i < (int)files.count(); i++) { + for(int i = 0; i < (int)files.size(); i++) { QString file = d.absoluteFilePath(files[i]); if (addFile(file)) { add_depend = true; @@ -116,7 +116,7 @@ ProjectGenerator::init() if(Option::projfile::do_pwd) knownDirs.prepend("."); const QString out_file = fileFixify(Option::output.fileName()); - for(int i = 0; i < knownDirs.count(); ++i) { + for(int i = 0; i < knownDirs.size(); ++i) { QString pd = knownDirs.at(i); if(exists(pd)) { QString newdir = pd; @@ -129,7 +129,7 @@ ProjectGenerator::init() subdirs.append(newdir); } else { QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files); - for(int i = 0; i < (int)profiles.count(); i++) { + for(int i = 0; i < (int)profiles.size(); i++) { QString nd = newdir; if(nd == ".") nd = ""; @@ -143,7 +143,7 @@ ProjectGenerator::init() } if (Option::recursive) { QStringList dirs = QDir(newdir).entryList(QDir::Dirs | QDir::NoDotAndDotDot); - for(int i = 0; i < (int)dirs.count(); i++) { + for(int i = 0; i < (int)dirs.size(); i++) { QString nd = fileFixify(newdir + QDir::separator() + dirs[i]); if (!knownDirs.contains(nd, Qt::CaseInsensitive)) knownDirs.append(nd); @@ -155,12 +155,12 @@ ProjectGenerator::init() int s = regx.lastIndexOf(Option::dir_sep); if(s != -1) { dir = regx.left(s+1); - regx = regx.right(regx.length() - (s+1)); + regx = regx.right(regx.size() - (s+1)); } QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regx), QDir::Dirs | QDir::NoDotAndDotDot); ProStringList &subdirs = v["SUBDIRS"]; - for(int i = 0; i < (int)files.count(); i++) { + for(int i = 0; i < (int)files.size(); i++) { QString newdir(dir + files[i]); QFileInfo fi(fileInfo(newdir)); { @@ -170,7 +170,7 @@ ProjectGenerator::init() subdirs.append(newdir); } else { QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files); - for(int i = 0; i < (int)profiles.count(); i++) { + for(int i = 0; i < (int)profiles.size(); i++) { QString nd = newdir + QDir::separator() + files[i]; fileFixify(nd); if(files[i] != "." && files[i] != ".." && !subdirs.contains(nd, Qt::CaseInsensitive)) { @@ -231,7 +231,7 @@ ProjectGenerator::init() } if(!h_ext.isEmpty()) { for(int cppit = 0; cppit < Option::cpp_ext.size(); ++cppit) { - QString src(dep.left(dep.length() - h_ext.length()) + + QString src(dep.left(dep.size() - h_ext.size()) + Option::cpp_ext.at(cppit)); if(exists(src)) { ProStringList &srcl = v["SOURCES"]; @@ -358,7 +358,7 @@ ProjectGenerator::addFile(QString file) int s = file.lastIndexOf(Option::dir_sep); if(s != -1) dir = file.left(s+1); - if(file.mid(dir.length(), Option::h_moc_mod.length()) == Option::h_moc_mod) + if(file.mid(dir.size(), Option::h_moc_mod.size()) == Option::h_moc_mod) return false; ProKey where; @@ -428,9 +428,9 @@ ProjectGenerator::getWritableVar(const char *vk, bool) else ret = v + " += "; QString join = vals.join(' '); - if(ret.length() + join.length() > 80) { + if(ret.size() + join.size() > 80) { QString spaces; - for(int i = 0; i < ret.length(); i++) + for(int i = 0; i < ret.size(); i++) spaces += " "; join = vals.join(" \\\n" + spaces); } diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 54c8d6e6a3..51f6ffe142 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -48,7 +48,7 @@ UnixMakefileGenerator::init() for (const ProString &iif : project->values("QMAKE_INTERNAL_INCLUDED_FILES")) { if (iif == project->cacheFile()) continue; - if (iif.startsWith(sroot) && iif.at(sroot.length()) == QLatin1Char('/')) + if (iif.startsWith(sroot) && iif.at(sroot.size()) == QLatin1Char('/')) project->values("DISTFILES") += fileFixify(iif.toQString(), FileFixifyRelative); } @@ -101,7 +101,7 @@ UnixMakefileGenerator::init() const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR"); for (int i = 0; i < rpathdirs.size(); ++i) { QString rpathdir = rpathdirs[i].toQString(); - if (rpathdir.length() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(') { + if (rpathdir.size() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(') { rpathdir.replace(0, 1, "\\$$"); // Escape from make and the shell } else if (!rpathdir.startsWith('@') && fileInfo(rpathdir).isRelative()) { QString rpathbase = project->first("QMAKE_REL_RPATH_BASE").toQString(); @@ -436,7 +436,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) break; } } else { - if (opt.length() == 10) + if (opt.size() == 10) ++it; // Skip } @@ -689,7 +689,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) QString link = Option::fixPathToTargetOS(destdir + links[i], false); int lslash = link.lastIndexOf(Option::dir_sep); if(lslash != -1) - link = link.right(link.length() - (lslash + 1)); + link = link.right(link.size() - (lslash + 1)); QString dst_link = escapeFilePath( filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute))); ret += "\n\t-$(SYMLINK) $(TARGET) " + dst_link; diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 98c7e217cf..eadcf5e02c 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -104,11 +104,11 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: if (!out_directory.isEmpty() && !out_directory.endsWith(Option::dir_sep)) out_directory += Option::dir_sep; if (!abs_source_path.isEmpty() && out_directory.startsWith(abs_source_path)) - out_directory = Option::output_dir + out_directory.mid(abs_source_path.length()); + out_directory = Option::output_dir + out_directory.mid(abs_source_path.size()); QString dist_directory = out_directory; if (dist_directory.endsWith(Option::dir_sep)) - dist_directory.chop(Option::dir_sep.length()); + dist_directory.chop(Option::dir_sep.size()); if (!dist_directory.startsWith(Option::dir_sep)) dist_directory.prepend(Option::dir_sep); @@ -120,7 +120,7 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator:: QString out = subtarget->makefile; QString in = escapeFilePath(fileFixify(in_directory + subtarget->profile, FileFixifyAbsolute)); if (out.startsWith(in_directory)) - out.remove(0, in_directory.length()); + out.remove(0, in_directory.size()); t << subtarget->target << "-distdir: FORCE"; writeSubTargetCall(t, in_directory, in, out_directory, escapeFilePath(out), @@ -302,7 +302,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit) { if((*it).endsWith((*cit))) { - d_file = (*it).left((*it).length() - (*cit).length()).toQString(); + d_file = (*it).left((*it).length() - (*cit).size()).toQString(); break; } } @@ -310,7 +310,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { if((*it).endsWith((*cppit))) { - d_file = (*it).left((*it).length() - (*cppit).length()).toQString(); + d_file = (*it).left((*it).length() - (*cppit).size()).toQString(); break; } } @@ -387,7 +387,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) //incremental target QString incr_target = var("TARGET") + "_incremental"; if(incr_target.indexOf(Option::dir_sep) != -1) - incr_target = incr_target.right(incr_target.length() - + incr_target = incr_target.right(incr_target.size() - (incr_target.lastIndexOf(Option::dir_sep) + 1)); QString incr_deps, incr_objs; if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { @@ -488,7 +488,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QString incr_target = var("QMAKE_ORIG_TARGET").replace( QRegularExpression("\\." + s_ext), "").replace(QRegularExpression("^lib"), "") + "_incremental"; if(incr_target.indexOf(Option::dir_sep) != -1) - incr_target = incr_target.right(incr_target.length() - + incr_target = incr_target.right(incr_target.size() - (incr_target.lastIndexOf(Option::dir_sep) + 1)); if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { @@ -849,7 +849,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) //copy other data if(!project->isEmpty("QMAKE_BUNDLE_DATA")) { const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA"); - for(int i = 0; i < bundle_data.count(); i++) { + for(int i = 0; i < bundle_data.size(); i++) { const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files")); QString path = bundle_dir; const ProKey pkey(bundle_data[i] + ".path"); @@ -869,7 +869,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } path += project->first(pkey).toQString(); path = Option::fixPathToTargetOS(path); - for(int file = 0; file < files.count(); file++) { + for(int file = 0; file < files.size(); file++) { QString fn = files.at(file).toQString(); QString src = fileFixify(fn, FileFixifyAbsolute); if (!QFile::exists(src)) @@ -1394,7 +1394,7 @@ UnixMakefileGenerator::libtoolFileName(bool fixify) QString ret = var("TARGET"); int slsh = ret.lastIndexOf(Option::dir_sep); if(slsh != -1) - ret = ret.right(ret.length() - slsh - 1); + ret = ret.right(ret.size() - slsh - 1); int dot = ret.indexOf('.'); if(dot != -1) ret = ret.left(dot); @@ -1464,7 +1464,7 @@ UnixMakefileGenerator::writeLibtoolFile() mkdir(fileInfo(fname).path()); int slsh = lname.lastIndexOf(Option::dir_sep); if(slsh != -1) - lname = lname.right(lname.length() - slsh - 1); + lname = lname.right(lname.size() - slsh - 1); QFile ft(fname); if(!ft.open(QIODevice::WriteOnly)) return; @@ -1494,7 +1494,7 @@ UnixMakefileGenerator::writeLibtoolFile() t << "'\n\n"; t << "# The name of the static archive.\n" - << "old_library='" << escapeFilePath(lname.left(lname.length()-Option::libtool_ext.length())) + << "old_library='" << escapeFilePath(lname.left(lname.size()-Option::libtool_ext.size())) << ".a'\n\n"; t << "# Libraries that this one depends upon.\n"; @@ -1557,9 +1557,9 @@ bool UnixMakefileGenerator::writeObjectsPart(QTextStream &t, bool do_incremental if (!increment) t << "\\\n\t\t" << (*objit); } - if (incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! + if (incrs_out.size() == objs.size()) { //we just switched places, no real incrementals to be done! t << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t")) << Qt::endl; - } else if (!incrs_out.count()) { + } else if (!incrs_out.size()) { t << Qt::endl; } else { src_incremental = true; diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index b8f6e54593..e2f89cb21d 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -250,7 +250,7 @@ void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t) if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET) 2>" << var("QMAKE_SHELL_NULL_DEVICE"); const ProString &objmax = project->first("QMAKE_LINK_OBJECT_MAX"); - if (objmax.isEmpty() || project->values("OBJECTS").count() < objmax.toInt()) { + if (objmax.isEmpty() || project->values("OBJECTS").size() < objmax.toInt()) { t << "\n\t$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ; } else { t << "\n\t" << objectsLinkLine << " " ; @@ -273,7 +273,7 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t) ProStringList rcIncPaths = project->values("RC_INCLUDEPATH"); rcIncPaths.prepend(fileInfo(rc_file).path()); QString incPathStr; - for (int i = 0; i < rcIncPaths.count(); ++i) { + for (int i = 0; i < rcIncPaths.size(); ++i) { const ProString &path = rcIncPaths.at(i); if (path.isEmpty()) continue; diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index ba3bc37088..7cbb44dde4 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -283,7 +283,7 @@ static QString commandLinesForOutput(QStringList commands) // As we want every sub-command to be error-checked (as is done by makefile-based // backends), we insert the checks ourselves, using the undocumented jump target. static QString errchk = QStringLiteral("if errorlevel 1 goto VCEnd"); - for (int i = commands.count() - 2; i >= 0; --i) { + for (int i = commands.size() - 2; i >= 0; --i) { if (!commands.at(i).startsWith("rem", Qt::CaseInsensitive)) commands.insert(i + 1, errchk); } @@ -301,7 +301,7 @@ static QStringList unquote(const QStringList &values) { QStringList result; result.reserve(values.size()); - for (int i = 0; i < values.count(); ++i) + for (int i = 0; i < values.size(); ++i) result << unquote(values.at(i)); return result; } @@ -544,7 +544,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) [] (const VCFilter &filter) { return filter.Name; }); tempProj.ExtraCompilers.removeDuplicates(); - for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) + for (int x = 0; x < tempProj.ExtraCompilers.size(); ++x) addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(x)); xmlFilter << closetag(); @@ -559,7 +559,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) outputFilter(tempProj, xml, xmlFilter, "Deployment Files"); outputFilter(tempProj, xml, xmlFilter, "Distribution Files"); - for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { + for (int x = 0; x < tempProj.ExtraCompilers.size(); ++x) { outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(x)); } @@ -574,7 +574,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) { - if (tool.SingleProjects.count() == 0) { + if (tool.SingleProjects.size() == 0) { warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); return; } @@ -589,7 +589,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << tag("ItemGroup") << attrTag("Label", "ProjectConfigurations"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) { + for (int i = 0; i < tool.SingleProjects.size(); ++i) { xml << tag("ProjectConfiguration") << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name) << tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName) @@ -613,7 +613,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) // config part. xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) + for (int i = 0; i < tool.SingleProjects.size(); ++i) write(xml, tool.SingleProjects.at(i).Configuration); xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); @@ -623,7 +623,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << closetag(); // PropertySheets - for (int i = 0; i < tool.SingleProjects.count(); ++i) { + for (int i = 0; i < tool.SingleProjects.size(); ++i) { xml << tag("ImportGroup") << attrTag("Condition", generateCondition(tool.SingleProjects.at(i).Configuration)) << attrTag("Label", "PropertySheets"); @@ -641,7 +641,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << closetag(); xml << tag("PropertyGroup"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) { + for (int i = 0; i < tool.SingleProjects.size(); ++i) { const VCConfiguration &config = tool.SingleProjects.at(i).Configuration; const QString condition = generateCondition(config); @@ -708,7 +708,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) } xml << closetag(); - for (int i = 0; i < tool.SingleProjects.count(); ++i) { + for (int i = 0; i < tool.SingleProjects.size(); ++i) { const VCConfiguration &config = tool.SingleProjects.at(i).Configuration; xml << tag("ItemDefinitionGroup") @@ -774,7 +774,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) addFilters(tool, xmlFilter, "Deployment Files"); addFilters(tool, xmlFilter, "Distribution Files"); - for (int x = 0; x < tool.ExtraCompilers.count(); ++x) + for (int x = 0; x < tool.ExtraCompilers.size(); ++x) addFilters(tool, xmlFilter, tool.ExtraCompilers.at(x)); xmlFilter << closetag(); @@ -788,7 +788,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) outputFilter(tool, xml, xmlFilter, "Resource Files"); outputFilter(tool, xml, xmlFilter, "Deployment Files"); outputFilter(tool, xml, xmlFilter, "Distribution Files"); - for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { + for (int x = 0; x < tool.ExtraCompilers.size(); ++x) { outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x)); } outputFilter(tool, xml, xmlFilter, "Root Files"); @@ -1737,7 +1737,7 @@ void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, cons { bool added = false; - for (int i = 0; i < project.SingleProjects.count(); ++i) { + for (int i = 0; i < project.SingleProjects.size(); ++i) { const VCFilter filter = project.SingleProjects.at(i).filterByName(filtername); if(!filter.Files.isEmpty() && !added) { xmlFilter << tag("Filter") @@ -1759,10 +1759,10 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu else root.reset(new XTreeNode); - for (int i = 0; i < project.SingleProjects.count(); ++i) { + for (int i = 0; i < project.SingleProjects.size(); ++i) { const VCFilter filter = project.SingleProjects.at(i).filterByName(filtername); // Merge all files in this filter to root tree - for (int x = 0; x < filter.Files.count(); ++x) + for (int x = 0; x < filter.Files.size(); ++x) root->addElement(filter.Files.at(x)); } @@ -1789,8 +1789,8 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml // We need to check if the file has any custom build step. // If there is one then it has to be included with "CustomBuild Include" bool hasCustomBuildStep = false; - QVarLengthArray<OutputFilterData> data(project.SingleProjects.count()); - for (int i = 0; i < project.SingleProjects.count(); ++i) { + QVarLengthArray<OutputFilterData> data(project.SingleProjects.size()); + for (int i = 0; i < project.SingleProjects.size(); ++i) { data[i].filter = project.SingleProjects.at(i).filterByName(cleanFilterName); if (!data[i].filter.Config) // only if the filter is not empty continue; @@ -1812,7 +1812,7 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml } bool fileAdded = false; - for (int i = 0; i < project.SingleProjects.count(); ++i) { + for (int i = 0; i < project.SingleProjects.size(); ++i) { OutputFilterData *d = &data[i]; if (!d->filter.Config) // only if the filter is not empty continue; diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 7e0eb4ed41..bc22ba9c8f 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -290,7 +290,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) for (int y = 0; directories[y]; y++) { QString dirTemp = project->first(directories[y]).toQString(); if (dirTemp.endsWith("\\")) - dirTemp.truncate(dirTemp.length()-1); + dirTemp.truncate(dirTemp.size()-1); if(!dirTemp.isEmpty()) source_directories.insert(dirTemp); } diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 62214bb66a..6943b6d0e7 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -1539,7 +1539,7 @@ bool VCLinkerTool::parseOption(const char* option) { QStringList both = QString(option+6).split(","); HeapReserveSize = both[0].toLongLong(); - if(both.count() == 2) + if(both.size() == 2) HeapCommitSize = both[1].toLongLong(); } break; @@ -1728,7 +1728,7 @@ bool VCLinkerTool::parseOption(const char* option) { QStringList both = QString(option+7).split(","); StackReserveSize = both[0].toLongLong(); - if(both.count() == 2) + if(both.size() == 2) StackCommitSize = both[1].toLongLong(); } break; @@ -2231,13 +2231,13 @@ void VCFilter::addFile(const VCFilterFile& fileInfo) void VCFilter::addFiles(const QStringList& fileList) { - for (int i = 0; i < fileList.count(); ++i) + for (int i = 0; i < fileList.size(); ++i) addFile(fileList.at(i)); } void VCFilter::addFiles(const ProStringList& fileList) { - for (int i = 0; i < fileList.count(); ++i) + for (int i = 0; i < fileList.size(); ++i) addFile(fileList.at(i).toQString()); } @@ -2304,7 +2304,7 @@ void VCFilter::modifyPCHstage(QString str) VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const { - for (int i = 0; i < Files.count(); ++i) { + for (int i = 0; i < Files.size(); ++i) { const VCFilterFile &f = Files.at(i); if (f.file == filePath) { *found = true; @@ -2330,7 +2330,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) hasBuiltIn = Project->hasBuiltinCompiler(objectMappedFile); // Remove the fake file suffix we've added initially to generate correct command lines. - inFile.chop(Project->customBuildToolFilterFileSuffix.length()); + inFile.chop(Project->customBuildToolFilterFileSuffix.size()); // qDebug("*** Extra compiler file has object mapped file '%s' => '%s'", qPrintable(inFile), qPrintable(objectMappedFile.join(' '))); } @@ -2342,7 +2342,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) CustomBuildTool.ToolPath.clear(); CustomBuildTool.ToolName = QLatin1String(_VCCustomBuildTool); - for (int x = 0; x < extraCompilers.count(); ++x) { + for (int x = 0; x < extraCompilers.size(); ++x) { const QString &extraCompilerName = extraCompilers.at(x); if (!Project->verifyExtraCompiler(extraCompilerName, inFile) && !hasBuiltIn) @@ -2387,7 +2387,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) configs.contains("dep_existing_only"), true /* checkCommandAvailability */); } - for (int i = 0; i < deps.count(); ++i) + for (int i = 0; i < deps.size(); ++i) deps[i] = Option::fixPathToTargetOS( Project->replaceExtraCompilerVariables( deps.at(i), inFile, out, MakefileGenerator::NoShell), @@ -2396,9 +2396,9 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) if (combined) { // Add dependencies for each file const ProStringList &tmp_in = Project->project->values(ProKey(extraCompilerName + ".input")); - for (int a = 0; a < tmp_in.count(); ++a) { + for (int a = 0; a < tmp_in.size(); ++a) { const ProStringList &files = Project->project->values(tmp_in.at(a).toKey()); - for (int b = 0; b < files.count(); ++b) { + for (int b = 0; b < files.size(); ++b) { QString file = files.at(b).toQString(); deps += Project->findDependencies(file); inputs += Option::fixPathToTargetOS(file, false); @@ -2432,7 +2432,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) } // Fixify paths - for (int i = 0; i < deps.count(); ++i) + for (int i = 0; i < deps.size(); ++i) deps[i] = Option::fixPathToTargetOS(deps[i], false); @@ -2450,7 +2450,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) deps += CustomBuildTool.AdditionalDependencies; // Make sure that all deps are only once QStringList uniqDeps; - for (int c = 0; c < deps.count(); ++c) { + for (int c = 0; c < deps.size(); ++c) { QString aDep = deps.at(c); if (!aDep.isEmpty()) uniqDeps << aDep; @@ -2496,7 +2496,7 @@ const VCFilter &VCProjectSingleConfig::filterByName(const QString &name) const const VCFilter &VCProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) const { - for (int i = 0; i < ExtraCompilersFiles.count(); ++i) + for (int i = 0; i < ExtraCompilersFiles.size(); ++i) if (ExtraCompilersFiles.at(i).Name == compilerName) return ExtraCompilersFiles.at(i); @@ -2576,7 +2576,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) outputFilter(tempProj, xml, "Distribution Files"); QSet<QString> extraCompilersInProject; - for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) { + for (int i = 0; i < tool.ExtraCompilersFiles.size(); ++i) { const QString &compilerName = tool.ExtraCompilersFiles.at(i).Name; if (!extraCompilersInProject.contains(compilerName)) { extraCompilersInProject += compilerName; @@ -2584,7 +2584,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) } } - for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { + for (int x = 0; x < tempProj.ExtraCompilers.size(); ++x) { outputFilter(tempProj, xml, tempProj.ExtraCompilers.at(x)); } outputFilter(tempProj, xml, "Root Files"); @@ -2595,7 +2595,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) { - if (tool.SingleProjects.count() == 0) { + if (tool.SingleProjects.size() == 0) { warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); return; } @@ -2615,7 +2615,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) << closetag(_Platforms) << tag(_Configurations); // Output each configuration - for (int i = 0; i < tool.SingleProjects.count(); ++i) + for (int i = 0; i < tool.SingleProjects.size(); ++i) write(xml, tool.SingleProjects.at(i).Configuration); xml << closetag(_Configurations) << tag(q_Files); @@ -2628,7 +2628,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) outputFilter(tool, xml, "Resource Files"); outputFilter(tool, xml, "Deployment Files"); outputFilter(tool, xml, "Distribution Files"); - for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { + for (int x = 0; x < tool.ExtraCompilers.size(); ++x) { outputFilter(tool, xml, tool.ExtraCompilers.at(x)); } outputFilter(tool, xml, "Root Files"); @@ -2930,7 +2930,7 @@ void VCProjectWriter::write(XmlOutput &xml, const VCConfiguration &tool) void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool) { - if(!tool.Files.count()) + if(!tool.Files.size()) return; if (!tool.Name.isEmpty()) { @@ -2940,7 +2940,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool) << attrS(_UniqueIdentifier, tool.Guid) << attrT(_ParseFiles, tool.ParseFiles); } - for (int i = 0; i < tool.Files.count(); ++i) { + for (int i = 0; i < tool.Files.size(); ++i) { const VCFilterFile &info = tool.Files.at(i); xml << tag(q_File) << attrS(_RelativePath, Option::fixPathToTargetOS(info.file)) @@ -2964,11 +2964,11 @@ void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QSt QString name, extfilter, guid; triState parse = unset; - for (int i = 0; i < project.SingleProjects.count(); ++i) { + for (int i = 0; i < project.SingleProjects.size(); ++i) { const VCFilter filter = project.SingleProjects.at(i).filterByName(filtername); // Merge all files in this filter to root tree - for (int x = 0; x < filter.Files.count(); ++x) + for (int x = 0; x < filter.Files.size(); ++x) root->addElement(filter.Files.at(x)); // Save filter setting from first filter. Next filters @@ -3003,7 +3003,7 @@ void VCProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, cons { xml << tag(q_File) << attrS(_RelativePath, Option::fixPathToTargetOS(info.file)); - for (int i = 0; i < project.SingleProjects.count(); ++i) { + for (int i = 0; i < project.SingleProjects.size(); ++i) { VCFilter filter = project.SingleProjects.at(i).filterByName(filtername); if (filter.Config) // only if the filter is not empty outputFileConfig(filter, xml, info.file); diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 6116ed9376..99cb4eff31 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -142,24 +142,24 @@ bool VcprojGenerator::writeProjectMakefile() // Generate project file if(project->first("TEMPLATE") == "vcapp" || project->first("TEMPLATE") == "vclib") { - if (!mergedProjects.count()) { + if (!mergedProjects.size()) { warn_msg(WarnLogic, "Generator: MSVC.NET: no single configuration created, cannot output project!"); return false; } debug_msg(1, "Generator: MSVC.NET: Writing project file"); VCProject mergedProject; - for (int i = 0; i < mergedProjects.count(); ++i) { + for (int i = 0; i < mergedProjects.size(); ++i) { VCProjectSingleConfig *singleProject = &(mergedProjects.at(i)->vcProject); mergedProject.SingleProjects += *singleProject; - for (int j = 0; j < singleProject->ExtraCompilersFiles.count(); ++j) { + for (int j = 0; j < singleProject->ExtraCompilersFiles.size(); ++j) { const QString &compilerName = singleProject->ExtraCompilersFiles.at(j).Name; if (!mergedProject.ExtraCompilers.contains(compilerName)) mergedProject.ExtraCompilers += compilerName; } } - if(mergedProjects.count() > 1 && + if(mergedProjects.size() > 1 && mergedProjects.at(0)->vcProject.Name == mergedProjects.at(1)->vcProject.Name) mergedProjects.at(0)->writePrlFile(); @@ -418,7 +418,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt newDep->uuid = tmp_proj.isEmpty("QMAKE_UUID") ? getProjectUUID(Option::fixPathToLocalOS(vcprojDir + QDir::separator() + vcproj)).toString().toUpper(): tmp_proj.first("QMAKE_UUID").toQString(); // We want to store it as the .lib name. if (newDep->target.endsWith(".dll")) - newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; + newDep->target = newDep->target.left(newDep->target.size()-3) + "lib"; projGuids.insert(newDep->projectName, newDep->target); if (tmpList.size()) { @@ -634,10 +634,10 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) bool VcprojGenerator::hasBuiltinCompiler(const QString &file) { // Source files - for (int i = 0; i < Option::cpp_ext.count(); ++i) + for (int i = 0; i < Option::cpp_ext.size(); ++i) if (file.endsWith(Option::cpp_ext.at(i))) return true; - for (int i = 0; i < Option::c_ext.count(); ++i) + for (int i = 0; i < Option::c_ext.size(); ++i) if (file.endsWith(Option::c_ext.at(i))) return true; if (file.endsWith(".rc") @@ -767,8 +767,8 @@ void VcprojGenerator::init() if (autogenPrecompSource) { precompSource = precompH + (pchIsCFile - ? (Option::c_ext.count() ? Option::c_ext.at(0) : QLatin1String(".c")) - : (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"))); + ? (Option::c_ext.size() ? Option::c_ext.at(0) : QLatin1String(".c")) + : (Option::cpp_ext.size() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"))); project->values("GENERATED_SOURCES") += precompSource; } else if (!precompSource.isEmpty()) { project->values("SOURCES") += precompSource; @@ -1213,7 +1213,7 @@ void VcprojGenerator::initDeploymentTool() continue; // We want to deploy .dlls not .libs if (dllName.endsWith(QLatin1String(".lib"))) - dllName.replace(dllName.length() - 3, 3, QLatin1String("dll")); + dllName.replace(dllName.size() - 3, 3, QLatin1String("dll")); // Use only the file name and check in Qt's install path and LIBPATHs to check for existence dllName.remove(0, dllName.lastIndexOf(QLatin1Char('/')) + 1); QFileInfo info; @@ -1553,7 +1553,7 @@ void VcprojGenerator::initExtraCompilerOutputs() } else if (!inputVars.isEmpty()) { // One output file per input const ProStringList &tmp_in = project->values(inputVars.first().toKey()); - for (int i = 0; i < tmp_in.count(); ++i) { + for (int i = 0; i < tmp_in.size(); ++i) { const QString &filename = tmp_in.at(i).toQString(); if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename)) extraCompile.addFile(Option::fixPathToTargetOS( @@ -1568,7 +1568,7 @@ void VcprojGenerator::initExtraCompilerOutputs() for (const ProString &inputVar : inputVars) { if (!otherFilters.contains(inputVar)) { const ProStringList &tmp_in = project->values(inputVar.toKey()); - for (int i = 0; i < tmp_in.count(); ++i) { + for (int i = 0; i < tmp_in.size(); ++i) { const QString &filename = tmp_in.at(i).toQString(); if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename)) extraCompile.addFile(Option::fixPathToTargetOS( diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 4f56bad28a..c8317389f5 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -174,9 +174,9 @@ bool Win32MakefileGenerator::processPrlFileBase(QString &origFile, QStringView o { if (MakefileGenerator::processPrlFileBase(origFile, origName, fixedBase, slashOff)) return true; - for (int off = fixedBase.length(); off > slashOff; off--) { + for (int off = fixedBase.size(); off > slashOff; off--) { if (!fixedBase.at(off - 1).isDigit()) { - if (off != fixedBase.length()) { + if (off != fixedBase.size()) { return MakefileGenerator::processPrlFileBase( origFile, origName, fixedBase.left(off), slashOff); } @@ -479,8 +479,8 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t) const int commandlineLimit = 2047; // NT limit, expanded for (ProStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { file = ' ' + escapeFilePath(Option::fixPathToTargetOS((*it).toQString())); - if(del_statement.length() + files.length() + - qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) { + if(del_statement.size() + files.size() + + qMax(fixEnvVariables(file).size(), file.size()) > commandlineLimit) { t << "\n\t" << del_statement << files; files.clear(); } @@ -508,8 +508,8 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t) const int commandlineLimit = 2047; // NT limit, expanded for (ProStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { file = " " + escapeFilePath(Option::fixPathToTargetOS((*it).toQString())); - if(del_statement.length() + files.length() + - qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) { + if(del_statement.size() + files.size() + + qMax(fixEnvVariables(file).size(), file.size()) > commandlineLimit) { t << "\n\t" << del_statement << files; files.clear(); } @@ -686,7 +686,7 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t) const ProStringList rcIncPaths = project->values("RC_INCLUDEPATH"); QString incPathStr; - for (int i = 0; i < rcIncPaths.count(); ++i) { + for (int i = 0; i < rcIncPaths.size(); ++i) { const ProString &path = rcIncPaths.at(i); if (path.isEmpty()) continue; @@ -749,7 +749,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t) QString dst_prl = Option::fixPathToTargetOS(project->first("QMAKE_INTERNAL_PRL_FILE").toQString()); int slsh = dst_prl.lastIndexOf(Option::dir_sep); if(slsh != -1) - dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); + dst_prl = dst_prl.right(dst_prl.size() - slsh - 1); dst_prl = filePrefixRoot(root, targetdir + dst_prl); if (!ret.isEmpty()) ret += "\n\t"; diff --git a/qmake/generators/xmloutput.cpp b/qmake/generators/xmloutput.cpp index 713c1eca44..be64176f33 100644 --- a/qmake/generators/xmloutput.cpp +++ b/qmake/generators/xmloutput.cpp @@ -240,9 +240,9 @@ void XmlOutput::closeTag() { switch(currentState) { case Bare: - if (tagStack.count()) + if (tagStack.size()) //warn_msg(WarnLogic, "<Root>: Cannot close tag in Bare state, %d tags on stack", tagStack.count()); - qDebug("<Root>: Cannot close tag in Bare state, %d tags on stack", int(tagStack.count())); + qDebug("<Root>: Cannot close tag in Bare state, %d tags on stack", int(tagStack.size())); else //warn_msg(WarnLogic, "<Root>: Cannot close tag, no tags on stack"); qDebug("<Root>: Cannot close tag, no tags on stack"); @@ -271,7 +271,7 @@ void XmlOutput::closeTo(const QString &tag) qDebug("<%s>: Cannot close to tag <%s>, not on stack", tagStack.last().toLatin1().constData(), tag.toLatin1().constData()); return; } - int left = tagStack.count(); + int left = tagStack.size(); while (left-- && cont) { cont = tagStack.last().compare(tag) != 0; closeTag(); @@ -280,7 +280,7 @@ void XmlOutput::closeTo(const QString &tag) void XmlOutput::closeAll() { - if (!tagStack.count()) + if (!tagStack.size()) return; closeTo(QString()); } @@ -315,7 +315,7 @@ void XmlOutput::addAttribute(const QString &attribute, const QString &value) case Tag: //warn_msg(WarnLogic, "<%s>: Cannot add attribute since tags not open", tagStack.last().toLatin1().constData()); qDebug("<%s>: Cannot add attribute (%s) since tag's not open", - (tagStack.count() ? tagStack.last().toLatin1().constData() : "Root"), + (tagStack.size() ? tagStack.last().toLatin1().constData() : "Root"), attribute.toLatin1().constData()); return; case Attribute: @@ -333,7 +333,7 @@ void XmlOutput::addAttributeTag(const QString &attribute, const QString &value) case Tag: //warn_msg(WarnLogic, "<%s>: Cannot add attribute since tags not open", tagStack.last().toLatin1().constData()); qDebug("<%s>: Cannot add attribute (%s) since tag's not open", - (tagStack.count() ? tagStack.last().toLatin1().constData() : "Root"), + (tagStack.size() ? tagStack.last().toLatin1().constData() : "Root"), attribute.toLatin1().constData()); return; case Attribute: diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 5a5c455264..71bf0020c0 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -136,7 +136,7 @@ bool isSpecialChar(ushort c, const uchar (&iqm)[16]) inline static bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16]) { - for (int x = arg.length() - 1; x >= 0; --x) { + for (int x = arg.size() - 1; x >= 0; --x) { if (isSpecialChar(arg.unicode()[x].unicode(), iqm)) return true; } @@ -151,7 +151,7 @@ QString IoUtils::shellQuoteUnix(const QString &arg) 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78 }; // 0-32 \'"$`<>|;&(){}*?#!~[] - if (!arg.length()) + if (!arg.size()) return QString::fromLatin1("''"); QString ret(arg); @@ -179,7 +179,7 @@ QString IoUtils::shellQuoteWin(const QString &arg) 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 }; // &()<>^| - if (!arg.length()) + if (!arg.size()) return QString::fromLatin1("\"\""); QString ret(arg); @@ -195,7 +195,7 @@ QString IoUtils::shellQuoteWin(const QString &arg) // to the called process verbatim. In the unquoted state, the circumflex escapes // meta chars (including itself and quotes), and is removed from the command. bool quoted = true; - for (int i = 0; i < ret.length(); i++) { + for (int i = 0; i < ret.size(); i++) { QChar c = ret.unicode()[i]; if (c.unicode() == '"') quoted = !quoted; diff --git a/qmake/library/proitems.cpp b/qmake/library/proitems.cpp index 1843f693d5..56d2e96d1c 100644 --- a/qmake/library/proitems.cpp +++ b/qmake/library/proitems.cpp @@ -40,13 +40,13 @@ ProString::ProString(const ProString &other, OmitPreHashing) : } ProString::ProString(const QString &str, DoPreHashing) : - m_string(str), m_offset(0), m_length(str.length()), m_file(0) + m_string(str), m_offset(0), m_length(str.size()), m_file(0) { updatedHash(); } ProString::ProString(const QString &str) : - m_string(str), m_offset(0), m_length(str.length()), m_file(0), m_hash(0x80000000) + m_string(str), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000) { } @@ -84,7 +84,7 @@ ProString::ProString(const QString &str, int offset, int length) : void ProString::setValue(const QString &str) { - m_string = str, m_offset = 0, m_length = str.length(), m_hash = 0x80000000; + m_string = str, m_offset = 0, m_length = str.size(), m_hash = 0x80000000; } size_t ProString::updatedHash() const @@ -121,7 +121,7 @@ ProKey::ProKey(const QString &str, int off, int len, uint hash) : void ProKey::setValue(const QString &str) { - m_string = str, m_offset = 0, m_length = str.length(); + m_string = str, m_offset = 0, m_length = str.size(); updatedHash(); } @@ -144,7 +144,7 @@ ProString &ProString::prepend(const ProString &other) } else { m_string = other.toQStringView() + toQStringView(); m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); if (!m_file) m_file = other.m_file; m_hash = 0x80000000; @@ -156,10 +156,10 @@ ProString &ProString::prepend(const ProString &other) ProString &ProString::append(const QLatin1String other) { if (other.size()) { - if (m_length != m_string.length()) { + if (m_length != m_string.size()) { m_string = toQStringView() + other; m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); } else { Q_ASSERT(m_offset == 0); m_string.append(other); @@ -172,10 +172,10 @@ ProString &ProString::append(const QLatin1String other) ProString &ProString::append(QChar other) { - if (m_length != m_string.length()) { + if (m_length != m_string.size()) { m_string = toQStringView() + other; m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); } else { Q_ASSERT(m_offset == 0); m_string.append(other); @@ -192,14 +192,14 @@ ProString &ProString::append(const ProString &other, bool *pending) if (!m_length) { *this = other; } else { - if (m_length != m_string.length()) + if (m_length != m_string.size()) m_string = toQString(); if (pending && !*pending) { m_string += QLatin1Char(' ') + other.toQStringView(); } else { m_string += other.toQStringView(); } - m_length = m_string.length(); + m_length = m_string.size(); m_offset = 0; if (other.m_file) m_file = other.m_file; @@ -242,7 +242,7 @@ ProString &ProString::append(const ProStringList &other, bool *pending, bool ski const ProString &str = other.at(i); m_string += str.toQStringView(); } - m_length = m_string.length(); + m_length = m_string.size(); if (other.last().m_file) m_file = other.last().m_file; m_hash = 0x80000000; diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index df7236f106..216a48148c 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -225,12 +225,12 @@ QMakeEvaluator::getMemberArgs(const ProKey &func, int srclen, const ProStringLis int *start, int *end) { *start = 0, *end = 0; - if (args.count() >= 2) { + if (args.size() >= 2) { bool ok = true; const ProString &start_str = args.at(1); *start = start_str.toInt(&ok); if (!ok) { - if (args.count() == 2) { + if (args.size() == 2) { int dotdot = start_str.indexOf(statics.strDotDot); if (dotdot != -1) { *start = start_str.left(dotdot).toInt(&ok); @@ -246,7 +246,7 @@ QMakeEvaluator::getMemberArgs(const ProKey &func, int srclen, const ProStringLis } } else { *end = *start; - if (args.count() == 3) + if (args.size() == 3) *end = args.at(2).toInt(&ok); if (!ok) { ProStringRoUser u1(func, m_tmp1); @@ -595,7 +595,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( var = args[0]; sep = args.at(1).toQString(); beg = args.at(2).toInt(); - if (args.count() == 4) + if (args.size() == 4) end = args.at(3).toInt(); } else { var = args[0]; @@ -630,7 +630,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( case E_SPRINTF: { ProStringRwUser u1(args.at(0), m_tmp1); QString tmp = u1.str(); - for (int i = 1; i < args.count(); ++i) + for (int i = 1; i < args.size(); ++i) tmp = tmp.arg(args.at(i).toQStringView()); ret << u1.extract(tmp); break; @@ -642,7 +642,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( bool zeropad = false; bool leftalign = false; enum { DefaultSign, PadSign, AlwaysSign } sign = DefaultSign; - if (args.count() >= 2) { + if (args.size() >= 2) { const auto opts = split_value_list(args.at(1).toQStringView()); for (const ProString &opt : opts) { if (opt.startsWith(QLatin1String("ibase="))) { @@ -687,7 +687,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( outstr = QLatin1Char(' '); } QString numstr = QString::number(num, obase); - int space = width - outstr.length() - numstr.length(); + int space = width - outstr.size() - numstr.size(); if (space <= 0) { outstr += numstr; } else if (leftalign) { @@ -722,11 +722,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( } case E_JOIN: { ProString glue, before, after; - if (args.count() >= 2) + if (args.size() >= 2) glue = args.at(1); - if (args.count() >= 3) + if (args.size() >= 3) before = args[2]; - if (args.count() == 4) + if (args.size() == 4) after = args[3]; const ProStringList &var = values(map(args.at(0))); if (!var.isEmpty()) { @@ -742,7 +742,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( } case E_SPLIT: { ProStringRoUser u1(m_tmp1); - const QString &sep = (args.count() == 2) ? u1.set(args.at(1)) : statics.field_sep; + const QString &sep = (args.size() == 2) ? u1.set(args.at(1)) : statics.field_sep; const auto vars = values(map(args.at(0))); for (const ProString &var : vars) { // FIXME: this is inconsistent with the "there are no empty strings" dogma. @@ -816,7 +816,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( bool blob = false; bool lines = false; bool singleLine = true; - if (args.count() > 1) { + if (args.size() > 1) { if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive)) singleLine = false; else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive)) @@ -883,7 +883,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( bool blob = false; bool lines = false; bool singleLine = true; - if (args.count() > 1) { + if (args.size() > 1) { if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive)) singleLine = false; else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive)) @@ -893,7 +893,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( } int exitCode; QByteArray bytes = getCommandOutput(args.at(0).toQString(), &exitCode); - if (args.count() > 2 && !args.at(2).isEmpty()) { + if (args.size() > 2 && !args.at(2).isEmpty()) { m_valuemapStack.top()[args.at(2).toKey()] = ProStringList(ProString(QString::number(exitCode))); } @@ -936,7 +936,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( for (int i = 0; i < args.size(); ++i) { QString str = args.at(i).toQString(); QChar *i_data = str.data(); - int i_len = str.length(); + int i_len = str.size(); for (int x = 0; x < i_len; ++x) { if (*(i_data+x) == QLatin1Char('\\') && x < i_len-1) { if (*(i_data+x+1) == QLatin1Char('\\')) { @@ -981,14 +981,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( case E_UPPER: case E_LOWER: case E_TITLE: - for (int i = 0; i < args.count(); ++i) { + for (int i = 0; i < args.size(); ++i) { ProStringRwUser u1(args.at(i), m_tmp1); QString rstr = u1.str(); if (func_t == E_UPPER) { rstr = rstr.toUpper(); } else { rstr = rstr.toLower(); - if (func_t == E_TITLE && rstr.length() > 0) + if (func_t == E_TITLE && rstr.size() > 0) rstr[0] = rstr.at(0).toTitleCase(); } ret << u1.extract(rstr); @@ -996,7 +996,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( break; case E_FILES: { bool recursive = false; - if (args.count() == 2) + if (args.size() == 2) recursive = isTrue(args.at(1)); QStringList dirs; ProStringRoUser u1(args.at(0), m_tmp1); @@ -1022,7 +1022,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( evalError(fL1S("section(): Encountered invalid wildcard expression '%1'.").arg(pattern)); goto allfail; } - for (int d = 0; d < dirs.count(); d++) { + for (int d = 0; d < dirs.size(); d++) { QString dir = dirs[d]; QDir qdir(pfx + dir); for (int i = 0, count = int(qdir.count()); i < count; ++i) { @@ -1044,7 +1044,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( ProStringRoUser u1(args.at(0), m_tmp1); QString msg = m_option->expandEnvVars(u1.str()); bool decorate = true; - if (args.count() == 2) + if (args.size() == 2) decorate = isTrue(args.at(1)); if (decorate) { if (!msg.endsWith(QLatin1Char('?'))) @@ -1091,10 +1091,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( ProValueMap dependees; QMultiMap<int, ProString> rootSet; ProStringList orgList = values(args.at(0).toKey()); - ProString prefix = args.count() < 2 ? ProString() : args.at(1); - ProString priosfx = args.count() < 4 ? ProString(".priority") : args.at(3); + ProString prefix = args.size() < 2 ? ProString() : args.at(1); + ProString priosfx = args.size() < 4 ? ProString(".priority") : args.at(3); populateDeps(orgList, prefix, - args.count() < 3 ? ProStringList(ProString(".depends")) + args.size() < 3 ? ProStringList(ProString(".depends")) : split_value_list(args.at(2).toQStringView()), priosfx, dependencies, dependees, rootSet); while (!rootSet.isEmpty()) { @@ -1131,7 +1131,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( case E_ABSOLUTE_PATH: { ProStringRwUser u1(args.at(0), m_tmp1); ProStringRwUser u2(m_tmp2); - QString baseDir = args.count() > 1 + QString baseDir = args.size() > 1 ? IoUtils::resolvePath(currentDirectory(), u2.set(args.at(1))) : currentDirectory(); QString rstr = u1.str().isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, u1.str()); @@ -1141,7 +1141,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( case E_RELATIVE_PATH: { ProStringRwUser u1(args.at(0), m_tmp1); ProStringRoUser u2(m_tmp2); - QString baseDir = args.count() > 1 + QString baseDir = args.size() > 1 ? IoUtils::resolvePath(currentDirectory(), u2.set(args.at(1))) : currentDirectory(); QString absArg = u1.str().isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, u1.str()); @@ -1252,7 +1252,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList & enum { TargetStash, TargetCache, TargetSuper } target = TargetCache; enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet; ProKey srcvar; - if (args.count() >= 2) { + if (args.size() >= 2) { const auto opts = split_value_list(args.at(1).toQStringView()); for (const ProString &opt : opts) { if (opt == QLatin1String("transient")) { @@ -1272,7 +1272,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList & return ReturnFalse; } } - if (args.count() >= 3) { + if (args.size() >= 3) { srcvar = args.at(2).toKey(); } else if (mode != CacheSet) { evalError(fL1S("cache(): modes other than 'set' require a source variable.")); @@ -1367,7 +1367,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList & varstr += QLatin1String(" -="); else varstr += QLatin1String(" ="); - if (diffval.count() == 1) { + if (diffval.size() == 1) { varstr += QLatin1Char(' '); varstr += quoteValue(diffval.at(0)); } else if (!diffval.isEmpty()) { @@ -1425,7 +1425,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( switch (func_t) { case T_DEFINED: { const ProKey &var = args.at(0).toKey(); - if (args.count() > 1) { + if (args.size() > 1) { if (args[1] == QLatin1String("test")) { return returnBool(m_functionDefs.testFunctions.contains(var)); } else if (args[1] == QLatin1String("replace")) { @@ -1512,7 +1512,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( VisitReturn ok = evaluateFileInto(fn, &vars, LoadProOnly); if (ok != ReturnTrue) return ok; - if (args.count() == 2) + if (args.size() == 2) return returnBool(vars.contains(map(args.at(1)))); QRegularExpression regx; regx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); @@ -1562,14 +1562,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( m_current.pro->fileName(), m_current.line); } case T_CONFIG: { - if (args.count() == 1) + if (args.size() == 1) return returnBool(isActiveConfig(args.at(0).toQStringView())); const auto mutuals = args.at(1).toQStringView().split(QLatin1Char('|'), Qt::SkipEmptyParts); const ProStringList &configs = values(statics.strCONFIG); for (int i = configs.size() - 1; i >= 0; i--) { - for (int mut = 0; mut < mutuals.count(); mut++) { + for (int mut = 0; mut < mutuals.size(); mut++) { if (configs[i].toQStringView() == mutuals[mut].trimmed()) return returnBool(configs[i] == args[0]); } @@ -1589,7 +1589,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( } } const ProStringList &l = values(map(args.at(0))); - if (args.count() == 2) { + if (args.size() == 2) { for (int i = 0; i < l.size(); ++i) { const ProString &val = l[i]; if (val == qry) @@ -1605,7 +1605,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( Qt::SkipEmptyParts); for (int i = l.size() - 1; i >= 0; i--) { const ProString &val = l[i]; - for (int mut = 0; mut < mutuals.count(); mut++) { + for (int mut = 0; mut < mutuals.size(); mut++) { if (val.toQStringView() == mutuals[mut].trimmed()) { if (val == qry) return ReturnTrue; @@ -1622,9 +1622,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ReturnFalse; } case T_COUNT: { - int cnt = values(map(args.at(0))).count(); + int cnt = values(map(args.at(0))).size(); int val = args.at(1).toInt(); - if (args.count() == 3) { + if (args.size() == 3) { const ProString &comp = args.at(2); if (comp == QLatin1String(">") || comp == QLatin1String("greaterThan")) { return returnBool(cnt > val); @@ -1710,10 +1710,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( LoadFlags flags; if (m_cumulative) flags = LoadSilent; - if (args.count() >= 2) { + if (args.size() >= 2) { if (!args.at(1).isEmpty()) parseInto = args.at(1) + QLatin1Char('.'); - if (args.count() >= 3 && isTrue(args.at(2))) + if (args.size() >= 3 && isTrue(args.at(2))) flags = LoadSilent; } QString fn = filePathEnvArg0(args); @@ -1745,7 +1745,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ok; } case T_LOAD: { - bool ignore_error = (args.count() == 2 && isTrue(args.at(1))); + bool ignore_error = (args.size() == 2 && isTrue(args.at(1))); VisitReturn ok = evaluateFeatureFile(m_option->expandEnvVars(args.at(0).toQString()), ignore_error); if (ok == ReturnFalse && ignore_error) @@ -1844,11 +1844,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( QIODevice::OpenMode mode = QIODevice::Truncate; QMakeVfs::VfsFlags flags = (m_cumulative ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact); QString contents; - if (args.count() >= 2) { + if (args.size() >= 2) { const ProStringList &vals = values(args.at(1).toKey()); if (!vals.isEmpty()) contents = vals.join(QLatin1Char('\n')) + QLatin1Char('\n'); - if (args.count() >= 3) { + if (args.size() >= 3) { const auto opts = split_value_list(args.at(2).toQStringView()); for (const ProString &opt : opts) { if (opt == QLatin1String("append")) { diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 2e4a3e27d1..4442601016 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -256,7 +256,7 @@ ProStringList QMakeEvaluator::split_value_list(QStringView vals, int source) source = currentFileId(); const QChar *vals_data = vals.data(); - const int vals_len = vals.length(); + const int vals_len = vals.size(); char16_t quote = 0; bool hadWord = false; for (int x = 0; x < vals_len; x++) { @@ -801,7 +801,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop( } else { ProString val; do { - if (index >= list.count()) + if (index >= list.size()) goto do_break; val = list.at(index++); } while (val.isEmpty()); // stupid, but qmake is like that @@ -853,19 +853,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable( if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError) return ReturnError; QStringView val = varVal.at(0).toQStringView(); - if (val.length() < 4 || val.at(0) != QLatin1Char('s')) { + if (val.size() < 4 || val.at(0) != QLatin1Char('s')) { evalError(fL1S("The ~= operator can handle only the s/// function.")); return ReturnTrue; } QChar sep = val.at(1); auto func = val.split(sep, Qt::KeepEmptyParts); - if (func.count() < 3 || func.count() > 4) { + if (func.size() < 3 || func.size() > 4) { evalError(fL1S("The s/// function expects 3 or 4 arguments.")); return ReturnTrue; } bool global = false, quote = false, case_sense = false; - if (func.count() == 4) { + if (func.size() == 4) { global = func[3].indexOf(QLatin1Char('g')) != -1; case_sense = func[3].indexOf(QLatin1Char('i')) == -1; quote = func[3].indexOf(QLatin1Char('q')) != -1; @@ -1545,7 +1545,7 @@ void QMakeEvaluator::updateFeaturePaths() feature_roots << (fb + features_concat); } - for (int i = 0; i < feature_roots.count(); ++i) + for (int i = 0; i < feature_roots.size(); ++i) if (!feature_roots.at(i).endsWith(QLatin1Char('/'))) feature_roots[i].append(QLatin1Char('/')); @@ -1570,7 +1570,7 @@ ProString QMakeEvaluator::propertyValue(const ProKey &name) const ProFile *QMakeEvaluator::currentProFile() const { - if (m_profileStack.count() > 0) + if (m_profileStack.size() > 0) return m_profileStack.top(); return nullptr; } @@ -1693,12 +1693,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFunction( m_locationStack.push(m_current); ProStringList args; - for (int i = 0; i < argumentsList.count(); ++i) { + for (int i = 0; i < argumentsList.size(); ++i) { args += argumentsList[i]; m_valuemapStack.top()[ProKey(QString::number(i+1))] = argumentsList[i]; } m_valuemapStack.top()[statics.strARGS] = args; - m_valuemapStack.top()[statics.strARGC] = ProStringList(ProString(QString::number(argumentsList.count()))); + m_valuemapStack.top()[statics.strARGC] = ProStringList(ProString(QString::number(argumentsList.size()))); vr = visitProBlock(func.pro(), func.tokPtr()); if (vr == ReturnReturn) vr = ReturnTrue; diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index 34c443b50e..91e7c3bb9c 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -89,7 +89,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( QMakeCmdLineParserState &state, QStringList &args, int *pos) { enum { ArgNone, ArgConfig, ArgSpec, ArgXSpec, ArgTmpl, ArgTmplPfx, ArgCache, ArgQtConf } argState = ArgNone; - for (; *pos < args.count(); (*pos)++) { + for (; *pos < args.size(); (*pos)++) { QString arg = args.at(*pos); switch (argState) { case ArgConfig: @@ -213,8 +213,8 @@ void QMakeGlobals::setDirectories(const QString &input_dir, const QString &outpu QString dstpath = output_dir; if (!dstpath.endsWith(QLatin1Char('/'))) dstpath += QLatin1Char('/'); - int srcLen = srcpath.length(); - int dstLen = dstpath.length(); + int srcLen = srcpath.size(); + int dstLen = dstpath.size(); int lastSl = -1; while (++lastSl, --srcLen, --dstLen, srcLen && dstLen && srcpath.at(srcLen) == dstpath.at(dstLen)) @@ -230,9 +230,9 @@ QString QMakeGlobals::shadowedPath(const QString &fileName) const if (source_root.isEmpty()) return fileName; if (fileName.startsWith(source_root) - && (fileName.length() == source_root.length() - || fileName.at(source_root.length()) == QLatin1Char('/'))) { - return build_root + fileName.mid(source_root.length()); + && (fileName.size() == source_root.size() + || fileName.at(source_root.size()) == QLatin1Char('/'))) { + return build_root + fileName.mid(source_root.size()); } return QString(); } @@ -243,7 +243,7 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const if (!val.isEmpty()) { QString cwd(QDir::currentPath()); const QStringList vals = val.split(dirlist_sep, Qt::SkipEmptyParts); - ret.reserve(vals.length()); + ret.reserve(vals.size()); for (const QString &it : vals) ret << IoUtils::resolvePath(cwd, it); } @@ -272,7 +272,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const startIndex = string.indexOf(QLatin1Char('$'), startIndex); if (startIndex < 0) break; - if (string.length() < startIndex + 3) + if (string.size() < startIndex + 3) break; if (string.at(startIndex + 1) != QLatin1Char('(')) { startIndex++; @@ -283,7 +283,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const break; QString value = getEnv(string.mid(startIndex + 2, endIndex - startIndex - 2)); string.replace(startIndex, endIndex - startIndex + 1, value); - startIndex += value.length(); + startIndex += value.size(); } return string; } diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp index 98540c93dc..fad4f7608d 100644 --- a/qmake/library/qmakeparser.cpp +++ b/qmake/library/qmakeparser.cpp @@ -334,7 +334,7 @@ void QMakeParser::read(ProFile *pro, QStringView in, int line, SubGrammar gramma xprStack.reserve(10); const ushort *cur = (const ushort *)in.data(); - const ushort *inend = cur + in.length(); + const ushort *inend = cur + in.size(); m_canElse = false; freshLine: m_state = StNew; @@ -732,7 +732,7 @@ void QMakeParser::read(ProFile *pro, QStringView in, int line, SubGrammar gramma if (!m_blockstack.top().braceLevel) { parseError(fL1S("Excess closing brace.")); } else if (!--m_blockstack.top().braceLevel - && m_blockstack.count() != 1) { + && m_blockstack.size() != 1) { leaveScope(tokPtr); m_state = StNew; m_canElse = false; @@ -1246,7 +1246,7 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort // The string is typically longer than the variable reference, so we need // to ensure that there is enough space in the output buffer - as unlikely // as an overflow is to actually happen in practice. - int need = (in.length() - (cur - (const ushort *)in.constData()) + 2) * 5 + out.length(); + int need = (in.size() - (cur - (const ushort *)in.constData()) + 2) * 5 + out.size(); int tused = *tokPtr - (ushort *)tokBuff->constData(); int xused; int total; @@ -1277,9 +1277,9 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort } xprPtr -= 2; // Was set up for variable reference xprPtr[-2] = TokLiteral | needSep; - xprPtr[-1] = out.length(); - memcpy(xprPtr, out.constData(), out.length() * 2); - *ptr = xprPtr + out.length(); + xprPtr[-1] = out.size(); + memcpy(xprPtr, out.constData(), out.size() * 2); + *ptr = xprPtr + out.size(); return true; } @@ -1539,7 +1539,7 @@ QString QMakeParser::formatProBlock(const QString &block) QString outStr; outStr += fL1S("\n << TS("); int offset = 0; - getBlock(reinterpret_cast<const ushort *>(block.constData()), block.length(), + getBlock(reinterpret_cast<const ushort *>(block.constData()), block.size(), offset, &outStr, 0); outStr += QLatin1Char(')'); return outStr; diff --git a/qmake/main.cpp b/qmake/main.cpp index e546b1705c..d6a47b2372 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -479,7 +479,7 @@ int runQMake(int argc, char **argv) Option::output_dir = dir.path(); QString absoluteFilePath = QDir::cleanPath(fi.absoluteFilePath()); - Option::output.setFileName(absoluteFilePath.mid(Option::output_dir.length() + 1)); + Option::output.setFileName(absoluteFilePath.mid(Option::output_dir.size() + 1)); } QMakeProperty prop; @@ -531,7 +531,7 @@ int runQMake(int argc, char **argv) if(!qmake_setpwd(fn.left(di))) fprintf(stderr, "Cannot find directory: %s\n", QDir::toNativeSeparators(fn.left(di)).toLatin1().constData()); - fn = fn.right(fn.length() - di - 1); + fn = fn.right(fn.size() - di - 1); } Option::prepareProject(fn); diff --git a/qmake/option.cpp b/qmake/option.cpp index f0e6c50341..1ffdaed4de 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -76,7 +76,7 @@ static Option::QMAKE_MODE default_mode(QString progname) { int s = progname.lastIndexOf(QDir::separator()); if(s != -1) - progname = progname.right(progname.length() - (s + 1)); + progname = progname.right(progname.size() - (s + 1)); if(progname == "qmakegen") return Option::QMAKE_GENERATE_PROJECT; else if(progname == "qt-config") @@ -95,7 +95,7 @@ static QString detectProjectFile(const QString &path, QString *singleProFileCand ret = candidate; } else { //last try.. QStringList profiles = dir.entryList(QStringList("*" + Option::pro_ext)); - if(profiles.count() == 1) + if(profiles.size() == 1) ret = dir.filePath(profiles.at(0)); } return ret; @@ -173,7 +173,7 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state) { enum { ArgNone, ArgOutput } argState = ArgNone; int x = 0; - while (x < args.count()) { + while (x < args.size()) { switch (argState) { case ArgOutput: Option::output.setFileName(args.at(x--)); @@ -389,7 +389,7 @@ Option::init(int argc, char **argv) } else if (opt == "-qtconf") { // Skip "-qtconf <file>" and proceed. ++idx; - if (idx + 1 < args.length()) + if (idx + 1 < args.size()) ++idx; continue; } else { @@ -464,7 +464,7 @@ bool Option::postProcessProject(QMakeProject *project) if (!project->buildRoot().isEmpty() && Option::output_dir.startsWith(project->buildRoot())) Option::mkfile::cachefile_depth = - Option::output_dir.mid(project->buildRoot().length()).count('/'); + Option::output_dir.mid(project->buildRoot().size()).count('/'); return true; } @@ -527,7 +527,7 @@ Option::fixString(QString string, uchar flags) if ((string.startsWith("\"") && string.endsWith("\"")) || (string.startsWith("\'") && string.endsWith("\'"))) - string = string.mid(1, string.length()-2); + string = string.mid(1, string.size()-2); //cache //qDebug() << "Fix" << orig_string << "->" << string; diff --git a/qmake/propertyprinter.cpp b/qmake/propertyprinter.cpp index 6ba2f76363..4ba56327e6 100644 --- a/qmake/propertyprinter.cpp +++ b/qmake/propertyprinter.cpp @@ -10,7 +10,7 @@ QT_BEGIN_NAMESPACE void qmakePropertyPrinter(const QList<QPair<QString, QString>> &values) { // Assume single property request - if (values.count() == 1) { + if (values.size() == 1) { std::cout << qPrintable(values.at(0).second) << std::endl; return; } diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 4a68eead8f..531eb2372b 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -76,7 +76,7 @@ void QMakeLibraryInfo::sysrootify(QString &path) if (sysroot.isEmpty()) return; - if (path.length() > 2 && path.at(1) == QLatin1Char(':') + if (path.size() > 2 && path.at(1) == QLatin1Char(':') && (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\'))) { path.replace(0, 2, sysroot); // Strip out the drive on Windows targets } else { @@ -217,7 +217,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group startIndex = ret.indexOf(QLatin1Char('$'), startIndex); if (startIndex < 0) break; - if (ret.length() < startIndex + 3) + if (ret.size() < startIndex + 3) break; if (ret.at(startIndex + 1) != QLatin1Char('(')) { startIndex++; @@ -231,7 +231,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group QString value = QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData())); ret.replace(startIndex, endIndex - startIndex + 1, value); - startIndex += value.length(); + startIndex += value.size(); } config->endGroup(); diff --git a/src/concurrent/qtconcurrentiteratekernel.h b/src/concurrent/qtconcurrentiteratekernel.h index 86150f1d97..8df873dbad 100644 --- a/src/concurrent/qtconcurrentiteratekernel.h +++ b/src/concurrent/qtconcurrentiteratekernel.h @@ -65,7 +65,7 @@ public: void reserveSpace(int resultCount) { currentResultCount = resultCount; - resizeList(qMax(resultCount, vector.count())); + resizeList(qMax(resultCount, vector.size())); } void reportResults(int begin) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index d57ce4ef5f..46ed60d6d1 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -283,7 +283,7 @@ void QUnifiedTimer::updateAnimationTimers() QScopedValueRollback<bool> guard(insideTick, true); if (profilerCallback) profilerCallback(delta); - for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) { + for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.size(); ++currentAnimationIdx) { QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx); animation->updateAnimationsTime(delta); } @@ -294,7 +294,7 @@ void QUnifiedTimer::updateAnimationTimers() int QUnifiedTimer::runningAnimationCount() { int count = 0; - for (int i = 0; i < animationTimers.count(); ++i) + for (int i = 0; i < animationTimers.size(); ++i) count += animationTimers.at(i)->runningAnimationCount(); return count; } @@ -309,7 +309,7 @@ void QUnifiedTimer::localRestart() if (insideRestart) return; - if (!pausedAnimationTimers.isEmpty() && (animationTimers.count() + animationTimersToStart.count() == pausedAnimationTimers.count())) { + if (!pausedAnimationTimers.isEmpty() && (animationTimers.size() + animationTimersToStart.size() == pausedAnimationTimers.size())) { driver->stop(); int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish(); // use a precise timer if the pause will be short @@ -327,7 +327,7 @@ void QUnifiedTimer::restart() { { QScopedValueRollback<bool> guard(insideRestart, true); - for (int i = 0; i < animationTimers.count(); ++i) + for (int i = 0; i < animationTimers.size(); ++i) animationTimers.at(i)->restartAnimationTimer(); } @@ -568,7 +568,7 @@ void QAnimationTimer::updateAnimationsTime(qint64 delta) //when the CPU load is high if (delta) { QScopedValueRollback<bool> guard(insideTick, true); - for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { + for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) { QAbstractAnimation *animation = animations.at(currentAnimationIdx); int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 2b08ef7756..5be59543c8 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -247,7 +247,7 @@ public: void updateAnimationsTime(qint64 delta) override; //useful for profiling/debugging - int runningAnimationCount() override { return animations.count(); } + int runningAnimationCount() override { return animations.size(); } private Q_SLOTS: void startAnimations(); diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index 5502942302..e8ffd99dcb 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -138,7 +138,7 @@ int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const void QAnimationGroup::addAnimation(QAbstractAnimation *animation) { Q_D(QAnimationGroup); - insertAnimation(d->animations.count(), animation); + insertAnimation(d->animations.size(), animation); } /*! @@ -261,7 +261,7 @@ void QAnimationGroupPrivate::clear(bool onDestruction) const QList<QAbstractAnimation *> animationsCopy = animations; // taking a copy animations.clear(); // Clearing backwards so the indices doesn't change while we remove animations. - for (int i = animationsCopy.count() - 1; i >= 0; --i) { + for (int i = animationsCopy.size() - 1; i >= 0; --i) { QAbstractAnimation *animation = animationsCopy.at(i); animation->setParent(nullptr); QAbstractAnimationPrivate::get(animation)->group = nullptr; diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 25d6d1de37..8e99d9cee0 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -172,7 +172,7 @@ void QSequentialAnimationGroupPrivate::rewindForwards(const AnimationIndex &newA // we need to force activation because setCurrentAnimation will have no effect activateCurrentAnimation(); else - setCurrentAnimation(animations.count() - 1, true); + setCurrentAnimation(animations.size() - 1, true); } // and now we need to fast rewind from the current position to @@ -396,7 +396,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter // currentAnimation.removeBindingUnlessInWrapper() // is not necessary here, since it is read only - index = qMin(index, animations.count() - 1); + index = qMin(index, animations.size() - 1); if (index == -1) { Q_ASSERT(animations.isEmpty()); @@ -517,7 +517,7 @@ void QSequentialAnimationGroupPrivate::animationRemoved(int index, QAbstractAnim disconnectUncontrolledAnimation(currentAnimation); - if (index < animations.count()) + if (index < animations.size()) setCurrentAnimation(index); //let's try to take the next one else if (index > 0) setCurrentAnimation(index - 1); diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index cd9a01a138..cf84200f2a 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -156,7 +156,7 @@ void QVariantAnimationPrivate::convertValues(int t) { auto type = QMetaType(t); //this ensures that all the keyValues are of type t - for (int i = 0; i < keyValues.count(); ++i) { + for (int i = 0; i < keyValues.size(); ++i) { QVariantAnimation::KeyValue &pair = keyValues[i]; pair.second.convert(type); } @@ -190,7 +190,7 @@ void QVariantAnimationPrivate::updateInterpolator() void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) { // can't interpolate if we don't have at least 2 values - if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) + if ((keyValues.size() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) return; const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0); @@ -207,7 +207,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) animationValueLessThan); if (it == keyValues.constBegin()) { //the item pointed to by it is the start element in the range - if (it->first == 0 && keyValues.count() > 1) { + if (it->first == 0 && keyValues.size() > 1) { currentInterval.start = *it; currentInterval.end = *(it+1); } else { @@ -216,7 +216,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) } } else if (it == keyValues.constEnd()) { --it; //position the iterator on the last item - if (it->first == 1 && keyValues.count() > 1) { + if (it->first == 1 && keyValues.size() > 1) { //we have an end value (item with progress = 1) currentInterval.start = *(it-1); currentInterval.end = *it; @@ -405,7 +405,7 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun // to continue causes the app to crash on exit with a SEGV if (interpolators) { const auto locker = qt_scoped_lock(registeredInterpolatorsMutex); - if (interpolationType >= interpolators->count()) + if (interpolationType >= interpolators->size()) interpolators->resize(interpolationType + 1); interpolators->replace(interpolationType, func); } @@ -423,7 +423,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in QInterpolatorVector *interpolators = registeredInterpolators(); const auto locker = qt_scoped_lock(registeredInterpolatorsMutex); QVariantAnimation::Interpolator ret = nullptr; - if (interpolationType < interpolators->count()) { + if (interpolationType < interpolators->size()) { ret = interpolators->at(interpolationType); if (ret) return ret; } diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index edacddbb04..7b5b8bc67d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2283,19 +2283,19 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename, line.setRawData(ptr, eol - ptr); if (line.startsWith(idKey)) { - ptr += idKey.length(); + ptr += idKey.size(); v.productType = unquote(ptr, eol); continue; } if (line.startsWith(prettyNameKey)) { - ptr += prettyNameKey.length(); + ptr += prettyNameKey.size(); v.prettyName = unquote(ptr, eol); continue; } if (line.startsWith(versionKey)) { - ptr += versionKey.length(); + ptr += versionKey.size(); v.productVersion = unquote(ptr, eol); continue; } @@ -2332,7 +2332,7 @@ static bool readEtcLsbRelease(QUnixOSVersion &v) int fd = qt_safe_open(distrorelease, O_RDONLY); if (fd != -1) { QT_STATBUF sbuf; - if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) { + if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.size()) { // file apparently contains interesting information QByteArray buffer(sbuf.st_size, Qt::Uninitialized); buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index d931dfac48..ccbb4b217a 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -534,7 +534,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo startIndex = ret.indexOf(u'$', startIndex); if (startIndex < 0) break; - if (ret.length() < startIndex + 3) + if (ret.size() < startIndex + 3) break; if (ret.at(startIndex + 1) != u'(') { startIndex++; @@ -546,7 +546,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo auto envVarName = QStringView{ret}.mid(startIndex + 2, endIndex - startIndex - 2); QString value = QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData())); ret.replace(startIndex, endIndex - startIndex + 1, value); - startIndex += value.length(); + startIndex += value.size(); } config->endGroup(); diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 9ac70b3340..875067fced 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1153,7 +1153,7 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = timeTokenC; qsizetype spaceIdx = lexeme.indexOf(QChar::fromLatin1(' ')); if (spaceIdx > 0) - timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2)); + timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.size() - spaceIdx - 2)); else timeArgs.append(QString()); } else if (lexeme.startsWith(QLatin1StringView(backtraceTokenC))) { diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 8147f0e9ff..ad01a3dcd8 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -106,7 +106,7 @@ public: inline QDebug &operator<<(double t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(const char* t) { stream->ts << QString::fromUtf8(t); return maybeSpace(); } inline QDebug &operator<<(const char16_t *t) { stream->ts << QStringView(t); return maybeSpace(); } - inline QDebug &operator<<(const QString & t) { putString(t.constData(), size_t(t.length())); return maybeSpace(); } + inline QDebug &operator<<(const QString & t) { putString(t.constData(), size_t(t.size())); return maybeSpace(); } inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); } inline QDebug &operator<<(QUtf8StringView s) { putByteArray(reinterpret_cast<const char*>(s.data()), s.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QLatin1StringView t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 0525cd46a5..f71ce7caf5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -153,12 +153,12 @@ inline void QDirPrivate::setPath(const QString &path) { QString p = QDir::fromNativeSeparators(path); if (p.endsWith(u'/') - && p.length() > 1 + && p.size() > 1 #if defined(Q_OS_WIN) && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) #endif ) { - p.truncate(p.length() - 1); + p.truncate(p.size() - 1); } dirEntry = QFileSystemEntry(p, QFileSystemEntry::FromInternalPath()); @@ -1051,12 +1051,12 @@ void QDir::setNameFilters(const QStringList &nameFilters) */ void QDir::setSearchPaths(const QString &prefix, const QStringList &searchPaths) { - if (prefix.length() < 2) { + if (prefix.size() < 2) { qWarning("QDir::setSearchPaths: Prefix must be longer than 1 character"); return; } - for (int i = 0; i < prefix.length(); ++i) { + for (int i = 0; i < prefix.size(); ++i) { if (!prefix.at(i).isLetterOrNumber()) { qWarning("QDir::setSearchPaths: Prefix can only contain letters or numbers"); return; @@ -1262,7 +1262,7 @@ uint QDir::count() const { Q_D(const QDir); d->initFileLists(*this); - return d->files.count(); + return d->files.size(); } /*! @@ -2293,7 +2293,7 @@ static QString qt_cleanPath(const QString &path, bool *ok) QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization, ok); // Strip away last slash except for root directories - if (ret.length() > 1 && ret.endsWith(u'/')) { + if (ret.size() > 1 && ret.endsWith(u'/')) { #if defined (Q_OS_WIN) if (!(ret.length() == 3 && ret.at(1) == u':')) #endif diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index e622f3af0d..7f5480c274 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -295,7 +295,7 @@ void QFileSelectorPrivate::updateSelectors() QLatin1Char pathSep(','); QStringList envSelectors = QString::fromLatin1(qgetenv("QT_FILE_SELECTORS")) .split(pathSep, Qt::SkipEmptyParts); - if (envSelectors.count()) + if (envSelectors.size()) sharedData->staticSelectors << envSelectors; if (!qEnvironmentVariableIsEmpty(env_override)) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index b7cb5354b6..fba1063e9e 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -119,7 +119,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent break; const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); - for (qsizetype i = 0; i < paths.count(); i++) { + for (qsizetype i = 0; i < paths.size(); i++) { entry = QFileSystemEntry(QDir::cleanPath( paths.at(i) % u'/' % QStringView{filePath}.mid(prefixSeparator + 1))); // Recurse! diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 9036608e7d..0645952091 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -591,7 +591,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, Q_CHECK_FILE_NAME(link, link); QByteArray s = qt_readlink(link.nativeFilePath().constData()); - if (s.length() > 0) { + if (s.size() > 0) { QString ret; if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) fillMetaData(link, data, QFileSystemMetaData::DirectoryType); @@ -713,13 +713,13 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) QFileSystemEntry cur(currentPath()); result = cur.nativeFilePath(); } - if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { + if (!orig.isEmpty() && !(orig.size() == 1 && orig[0] == '.')) { if (!result.isEmpty() && !result.endsWith('/')) result.append('/'); result.append(orig); } - if (result.length() == 1 && result[0] == '/') + if (result.size() == 1 && result[0] == '/') return QFileSystemEntry(result, QFileSystemEntry::FromNativePath()); const bool isDir = result.endsWith('/'); @@ -1152,7 +1152,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo if (removeEmptyParents) { QString dirName = QDir::cleanPath(entry.filePath()); - for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { + for (int oldslash = 0, slash=dirName.size(); slash > 0; oldslash = slash) { const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; if (QT_STAT(chunk.constData(), &st) != -1) { diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 23698930c0..d924b22431 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -468,7 +468,7 @@ void QFSFileEnginePrivate::unmapAll() { if (!maps.isEmpty()) { const QList<uchar*> keys = maps.keys(); // Make a copy since unmap() modifies the map. - for (int i = 0; i < keys.count(); ++i) + for (int i = 0; i < keys.size(); ++i) unmap(keys.at(i)); } } diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 7eac497cea..5bee6c675b 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -779,7 +779,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const if (!root.endsWith(u'/')) root += u'/'; if (path.size() >= root.size() && path.startsWith(root)) - path = path.mid(root.length() - 1); + path = path.mid(root.size() - 1); if (path.isEmpty()) path = u'/'; } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 60622e3aaa..8d4a2adb81 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -343,7 +343,7 @@ void QSettingsPrivate::requestUpdate() QStringList QSettingsPrivate::variantListToStringList(const QVariantList &l) { QStringList result; - result.reserve(l.count()); + result.reserve(l.size()); for (auto v : l) result.append(variantToString(v)); return result; @@ -356,9 +356,9 @@ QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l) const QString &str = outStringList.at(i); if (str.startsWith(u'@')) { - if (str.length() < 2 || str.at(1) != u'@') { + if (str.size() < 2 || str.at(1) != u'@') { QVariantList variantList; - variantList.reserve(l.count()); + variantList.reserve(l.size()); for (const auto &s : l) variantList.append(stringToVariant(s)); return variantList; @@ -511,7 +511,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) void QSettingsPrivate::iniEscapedKey(const QString &key, QByteArray &result) { - result.reserve(result.length() + key.length() * 3 / 2); + result.reserve(result.size() + key.size() * 3 / 2); for (qsizetype i = 0; i < key.size(); ++i) { uint ch = key.at(i).unicode(); @@ -540,7 +540,7 @@ bool QSettingsPrivate::iniUnescapedKey(QByteArrayView key, QString &result) { const QString decoded = QString::fromUtf8(key); const qsizetype size = decoded.size(); - result.reserve(result.length() + size); + result.reserve(result.size() + size); qsizetype i = 0; bool lowercaseOnly = true; while (i < size) { @@ -735,7 +735,7 @@ StSkipSpaces: // fallthrough StNormal: - qsizetype chopLimit = stringResult.length(); + qsizetype chopLimit = stringResult.size(); while (i < str.size()) { switch (str.at(i)) { case '\\': @@ -773,7 +773,7 @@ StNormal: } else { // the character is skipped } - chopLimit = stringResult.length(); + chopLimit = stringResult.size(); break; case '"': ++i; @@ -860,7 +860,7 @@ end: QStringList QSettingsPrivate::splitArgs(const QString &s, qsizetype idx) { - qsizetype l = s.length(); + qsizetype l = s.size(); Q_ASSERT(l > 0); Q_ASSERT(s.at(idx) == u'('); Q_ASSERT(s.at(l - 1) == u')'); @@ -1515,7 +1515,7 @@ bool QConfFileSettingsPrivate::readIniLine(QByteArrayView data, qsizetype &dataP qsizetype &lineStart, qsizetype &lineLen, qsizetype &equalsPos) { - qsizetype dataLen = data.length(); + qsizetype dataLen = data.size(); bool inQuotes = false; equalsPos = -1; @@ -1643,7 +1643,7 @@ bool QConfFileSettingsPrivate::readIniFile(QByteArrayView data, ++position; } - Q_ASSERT(lineStart == data.length()); + Q_ASSERT(lineStart == data.size()); FLUSH_CURRENT_SECTION(); return ok; diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index e5122ff3b6..339f3c565e 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -260,16 +260,16 @@ QString QStandardPaths::writableLocation(StandardLocation type) QRegularExpressionMatch match = exp.match(line); if (match.hasMatch() && match.capturedView(1) == key) { QStringView value = match.capturedView(2); - if (value.length() > 2 + if (value.size() > 2 && value.startsWith(u'\"') && value.endsWith(u'\"')) - value = value.mid(1, value.length() - 2); + value = value.mid(1, value.size() - 2); // value can start with $HOME if (value.startsWith("$HOME"_L1)) result = QDir::homePath() + value.mid(5); else result = value.toString(); - if (result.length() > 1 && result.endsWith(u'/')) + if (result.size() > 1 && result.endsWith(u'/')) result.chop(1); } } @@ -371,7 +371,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) break; case AppConfigLocation: dirs = xdgConfigDirs(); - for (int i = 0; i < dirs.count(); ++i) + for (int i = 0; i < dirs.size(); ++i) appendOrganizationAndApp(dirs[i]); break; case GenericDataLocation: @@ -379,19 +379,19 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) break; case ApplicationsLocation: dirs = xdgDataDirs(); - for (int i = 0; i < dirs.count(); ++i) + for (int i = 0; i < dirs.size(); ++i) dirs[i].append("/applications"_L1); break; case AppDataLocation: case AppLocalDataLocation: dirs = xdgDataDirs(); - for (int i = 0; i < dirs.count(); ++i) + for (int i = 0; i < dirs.size(); ++i) appendOrganizationAndApp(dirs[i]); break; case FontsLocation: dirs += QDir::homePath() + "/.fonts"_L1; dirs += xdgDataDirs(); - for (int i = 1; i < dirs.count(); ++i) + for (int i = 1; i < dirs.size(); ++i) dirs[i].append("/fonts"_L1); break; default: diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index d09002af5a..be3bf0252d 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -714,8 +714,8 @@ void QStorageInfoPrivate::initRootPath() const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); // we try to find most suitable entry - if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) { - maxLength = mountDir.length(); + if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.size()) { + maxLength = mountDir.size(); rootPath = mountDir; device = it.device(); fileSystemType = fsName; diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 44c45a1cad..86ad1439e3 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -45,7 +45,7 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName) { // Ensure there is a placeholder mask QString qfilename = QDir::fromNativeSeparators(templateName); - uint phPos = qfilename.length(); + uint phPos = qfilename.size(); uint phLength = 0; while (phPos != 0) { @@ -75,7 +75,7 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName) .nativeFilePath(); // Find mask in native path - phPos = filename.length(); + phPos = filename.size(); phLength = 0; while (phPos != 0) { --phPos; @@ -109,8 +109,8 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName) QFileSystemEntry::NativePath QTemporaryFileName::generateNext() { Q_ASSERT(length != 0); - Q_ASSERT(pos < path.length()); - Q_ASSERT(length <= path.length() - pos); + Q_ASSERT(pos < path.size()); + Q_ASSERT(length <= path.size() - pos); Char *const placeholderStart = (Char *)path.data() + pos; Char *const placeholderEnd = placeholderStart + length; diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index c3122e27f2..737f32755b 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -510,7 +510,7 @@ public: ErrorCode validityError(QString *source = nullptr, qsizetype *position = nullptr) const; bool validateComponent(Section section, const QString &input, qsizetype begin, qsizetype end); bool validateComponent(Section section, const QString &input) - { return validateComponent(section, input, 0, input.length()); } + { return validateComponent(section, input, 0, input.size()); } // no QString scheme() const; void appendAuthority(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const; @@ -918,7 +918,7 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o } // check if we need to remove trailing slashes if (options & QUrl::StripTrailingSlash) { - while (thePathView.length() > 1 && thePathView.endsWith(u'/')) + while (thePathView.size() > 1 && thePathView.endsWith(u'/')) thePathView.chop(1); } @@ -1191,7 +1191,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar // uppercase the version, if necessary if (begin[2].unicode() >= 'a') - host[host.length() - 2] = QChar{begin[2].unicode() - 0x20}; + host[host.size() - 2] = QChar{begin[2].unicode() - 0x20}; begin += 4; --end; @@ -1341,7 +1341,7 @@ QUrlPrivate::setHost(const QString &value, qsizetype from, qsizetype iend, QUrl: } // recurse - return setHost(s, 0, s.length(), QUrl::StrictMode); + return setHost(s, 0, s.size(), QUrl::StrictMode); } s = qt_ACE_do(value.mid(from, iend - from), NormalizeAce, ForbidLeadingDot, {}); @@ -1377,7 +1377,7 @@ inline void QUrlPrivate::parse(const QString &url, QUrl::ParsingMode parsingMode qsizetype colon = -1; qsizetype question = -1; qsizetype hash = -1; - const qsizetype len = url.length(); + const qsizetype len = url.size(); const QChar *const begin = url.constData(); const ushort *const data = reinterpret_cast<const ushort *>(begin); @@ -1628,7 +1628,7 @@ inline QUrlPrivate::ErrorCode QUrlPrivate::validityError(QString *source, qsizet if (path.isEmpty()) return NoError; if (path.at(0) == u'/') { - if (hasAuthority() || path.length() == 1 || path.at(1) != u'/') + if (hasAuthority() || path.size() == 1 || path.at(1) != u'/') return NoError; if (source) { *source = path; @@ -1648,7 +1648,7 @@ inline QUrlPrivate::ErrorCode QUrlPrivate::validityError(QString *source, qsizet return NoError; // check for a path of "text:text/" - for (qsizetype i = 0; i < path.length(); ++i) { + for (qsizetype i = 0; i < path.size(); ++i) { ushort c = path.at(i).unicode(); if (c == '/') { // found the slash before the colon @@ -1956,7 +1956,7 @@ void QUrl::setScheme(const QString &scheme) d->flags &= ~QUrlPrivate::IsLocalFile; d->scheme.clear(); } else { - d->setScheme(scheme, scheme.length(), /* do set error */ true); + d->setScheme(scheme, scheme.size(), /* do set error */ true); } } @@ -2016,7 +2016,7 @@ void QUrl::setAuthority(const QString &authority, ParsingMode mode) return; } - d->setAuthority(authority, 0, authority.length(), mode); + d->setAuthority(authority, 0, authority.size(), mode); if (authority.isNull()) { // QUrlPrivate::setAuthority cleared almost everything // but it leaves the Host bit set @@ -2087,7 +2087,7 @@ void QUrl::setUserInfo(const QString &userInfo, ParsingMode mode) return; } - d->setUserInfo(trimmed, 0, trimmed.length()); + d->setUserInfo(trimmed, 0, trimmed.size()); if (userInfo.isNull()) { // QUrlPrivate::setUserInfo cleared almost everything // but it leaves the UserName bit set @@ -2159,7 +2159,7 @@ void QUrl::setUserName(const QString &userName, ParsingMode mode) mode = TolerantMode; } - d->setUserName(data, 0, data.length()); + d->setUserName(data, 0, data.size()); if (userName.isNull()) d->sectionIsPresent &= ~QUrlPrivate::UserName; else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::UserName, userName)) @@ -2222,7 +2222,7 @@ void QUrl::setPassword(const QString &password, ParsingMode mode) mode = TolerantMode; } - d->setPassword(data, 0, data.length()); + d->setPassword(data, 0, data.size()); if (password.isNull()) d->sectionIsPresent &= ~QUrlPrivate::Password; else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Password, password)) @@ -2284,7 +2284,7 @@ void QUrl::setHost(const QString &host, ParsingMode mode) mode = TolerantMode; } - if (d->setHost(data, 0, data.length(), mode)) { + if (d->setHost(data, 0, data.size(), mode)) { if (host.isNull()) d->sectionIsPresent &= ~QUrlPrivate::Host; } else if (!data.startsWith(u'[')) { @@ -2293,7 +2293,7 @@ void QUrl::setHost(const QString &host, ParsingMode mode) data.prepend(u'['); data.append(u']'); - if (!d->setHost(data, 0, data.length(), mode)) { + if (!d->setHost(data, 0, data.size(), mode)) { // failed again if (data.contains(u':')) { // source data contains ':', so it's an IPv6 error @@ -2330,7 +2330,7 @@ QString QUrl::host(ComponentFormattingOptions options) const if (d) { d->appendHost(result, options); if (result.startsWith(u'[')) - result = result.mid(1, result.length() - 2); + result = result.mid(1, result.size() - 2); } return result; } @@ -2409,7 +2409,7 @@ void QUrl::setPath(const QString &path, ParsingMode mode) mode = TolerantMode; } - d->setPath(data, 0, data.length()); + d->setPath(data, 0, data.size()); // optimized out, since there is no path delimiter // if (path.isNull()) @@ -2545,7 +2545,7 @@ void QUrl::setQuery(const QString &query, ParsingMode mode) mode = TolerantMode; } - d->setQuery(data, 0, data.length()); + d->setQuery(data, 0, data.size()); if (query.isNull()) d->sectionIsPresent &= ~QUrlPrivate::Query; else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Query, query)) @@ -2643,7 +2643,7 @@ void QUrl::setFragment(const QString &fragment, ParsingMode mode) mode = TolerantMode; } - d->setFragment(data, 0, data.length()); + d->setFragment(data, 0, data.size()); if (fragment.isNull()) d->sectionIsPresent &= ~QUrlPrivate::Fragment; else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Fragment, fragment)) @@ -2937,7 +2937,7 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const that.detach(); QString path; d->appendPath(path, options | FullyEncoded, QUrlPrivate::Path); - that.d->setPath(path, 0, path.length()); + that.d->setPath(path, 0, path.size()); } return that; } @@ -3346,7 +3346,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) QString deslashified = fromNativeSeparators(localFile); // magic for drives on windows - if (deslashified.length() > 1 && deslashified.at(1) == u':' && deslashified.at(0) != u'/') { + if (deslashified.size() > 1 && deslashified.at(1) == u':' && deslashified.at(0) != u'/') { deslashified.prepend(u'/'); } else if (deslashified.startsWith("//"_L1)) { // magic for shared drive on windows @@ -3367,7 +3367,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) // Path hostname is not a valid URL host, so set it entirely in the path // (by leaving deslashified unchanged) } else if (indexOfPath > 2) { - deslashified = deslashified.right(deslashified.length() - indexOfPath); + deslashified = deslashified.right(deslashified.size() - indexOfPath); } else { deslashified.clear(); } @@ -3431,16 +3431,16 @@ bool QUrl::isParentOf(const QUrl &childUrl) const if (!d) return ((childUrl.scheme().isEmpty()) && (childUrl.authority().isEmpty()) - && childPath.length() > 0 && childPath.at(0) == u'/'); + && childPath.size() > 0 && childPath.at(0) == u'/'); QString ourPath = path(); return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) - && ((ourPath.endsWith(u'/') && childPath.length() > ourPath.length()) - || (!ourPath.endsWith(u'/') && childPath.length() > ourPath.length() - && childPath.at(ourPath.length()) == u'/'))); + && ((ourPath.endsWith(u'/') && childPath.size() > ourPath.size()) + || (!ourPath.endsWith(u'/') && childPath.size() > ourPath.size() + && childPath.at(ourPath.size()) == u'/'))); } @@ -3488,7 +3488,7 @@ QDebug operator<<(QDebug d, const QUrl &url) static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition) { - QChar c = size_t(errorPosition) < size_t(errorSource.length()) ? + QChar c = size_t(errorPosition) < size_t(errorSource.size()) ? errorSource.at(errorPosition) : QChar(QChar::Null); switch (errorCode) { diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 04b9a25886..5fc6006ef4 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -73,11 +73,11 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output) // Do not try to encode strings that certainly will result in output // that is longer than allowable domain name label length. Note that // non-BMP codepoints are encoded as two QChars. - if (in.length() > MaxDomainLabelLength * 2) + if (in.size() > MaxDomainLabelLength * 2) return; - int outLen = output->length(); - output->resize(outLen + in.length()); + int outLen = output->size(); + output->resize(outLen + in.size()); QChar *d = output->data() + outLen; bool skipped = false; @@ -177,7 +177,7 @@ Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc) // Do not try to decode strings longer than allowable for a domain label. // Non-ASCII strings are not allowed here anyway, so there is no need // to account for surrogates. - if (pc.length() > MaxDomainLabelLength) + if (pc.size() > MaxDomainLabelLength) return QString(); // strip any ACE prefix @@ -468,7 +468,7 @@ static QString mapDomainName(const QString &in, QUrl::AceProcessingOptions optio */ static bool validateAsciiLabel(QStringView label) { - if (label.length() > MaxDomainLabelLength) + if (label.size() > MaxDomainLabelLength) return false; if (label.first() == u'-' || label.last() == u'-') @@ -709,7 +709,7 @@ bool DomainValidityChecker::checkLabel(const QString &label, QUrl::AceProcessing if (label != label.normalized(QString::NormalizationForm_C)) return false; - if (label.length() >= 4) { + if (label.size() >= 4) { // This assumes that the first two characters are in BMP, but that's ok // because non-BMP characters are unlikely to be used for specifying // future extensions. diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index ce8ed6414d..9b3015ecf0 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -515,7 +515,7 @@ QString QUrlQuery::query(QUrl::ComponentFormattingOptions encoding) const { int size = 0; for ( ; it != end; ++it) - size += it->first.length() + 1 + it->second.length() + 1; + size += it->first.size() + 1 + it->second.size() + 1; result.reserve(size + size / 4); } @@ -630,7 +630,7 @@ QList<QPair<QString, QString> > QUrlQuery::queryItems(QUrl::ComponentFormattingO QList<QPair<QString, QString> > result; Map::const_iterator it = d->itemList.constBegin(); Map::const_iterator end = d->itemList.constEnd(); - result.reserve(d->itemList.count()); + result.reserve(d->itemList.size()); for ( ; it != end; ++it) result << qMakePair(d->recodeToUser(it->first, encoding), d->recodeToUser(it->second, encoding)); diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index fcf6e69534..1cd4751bfb 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -840,13 +840,13 @@ void QAbstractItemModelPrivate::removePersistentIndexData(QPersistentModelIndexD Q_UNUSED(removed); } // make sure our optimization still works - for (int i = persistent.moved.count() - 1; i >= 0; --i) { + for (int i = persistent.moved.size() - 1; i >= 0; --i) { int idx = persistent.moved.at(i).indexOf(data); if (idx >= 0) persistent.moved[i].remove(idx); } // update the references to invalidated persistent indexes - for (int i = persistent.invalidated.count() - 1; i >= 0; --i) { + for (int i = persistent.invalidated.size() - 1; i >= 0; --i) { int idx = persistent.invalidated.at(i).indexOf(data); if (idx >= 0) persistent.invalidated[i].remove(idx); @@ -2120,7 +2120,7 @@ QStringList QAbstractItemModel::mimeTypes() const */ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const { - if (indexes.count() <= 0) + if (indexes.size() <= 0) return nullptr; QStringList types = mimeTypes(); if (types.isEmpty()) @@ -2159,7 +2159,7 @@ bool QAbstractItemModel::canDropMimeData(const QMimeData *data, Qt::DropAction a return false; const QStringList modelTypes = mimeTypes(); - for (int i = 0; i < modelTypes.count(); ++i) { + for (int i = 0; i < modelTypes.size(); ++i) { if (data->hasFormat(modelTypes.at(i))) return true; } @@ -2516,7 +2516,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, // iterates twice if wrapping for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) { - for (int r = from; (r < to) && (allHits || result.count() < hits); ++r) { + for (int r = from; (r < to) && (allHits || result.size() < hits); ++r) { QModelIndex idx = index(r, column, p); if (!idx.isValid()) continue; @@ -2582,7 +2582,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, if (hasChildren(parent)) { // search the hierarchy result += match(index(0, column, parent), role, (text.isEmpty() ? value : text), - (allHits ? -1 : hits - result.count()), flags); + (allHits ? -1 : hits - result.size()), flags); } } } @@ -2775,15 +2775,15 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare // Compute the number of continuous rows upon insertion and modify the rows to match QList<int> rowsToInsert(bottom + 1); - for (int i = 0; i < rows.count(); ++i) + for (int i = 0; i < rows.size(); ++i) rowsToInsert[rows.at(i)] = 1; - for (int i = 0; i < rowsToInsert.count(); ++i) { + for (int i = 0; i < rowsToInsert.size(); ++i) { if (rowsToInsert.at(i) == 1){ rowsToInsert[i] = dragRowCount; ++dragRowCount; } } - for (int i = 0; i < rows.count(); ++i) + for (int i = 0; i < rows.size(); ++i) rows[i] = top + rowsToInsert.at(rows.at(i)); QBitArray isWrittenTo(dragRowCount * dragColumnCount); @@ -3446,8 +3446,8 @@ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from, if (d->persistent.indexes.isEmpty()) return; QList<QPersistentModelIndexData *> toBeReinserted; - toBeReinserted.reserve(to.count()); - for (int i = 0; i < from.count(); ++i) { + toBeReinserted.reserve(to.size()); + for (int i = 0; i < from.size(); ++i) { if (from.at(i) == to.at(i)) continue; const auto it = d->persistent.indexes.constFind(from.at(i)); @@ -3473,7 +3473,7 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const { Q_D(const QAbstractItemModel); QModelIndexList result; - result.reserve(d->persistent.indexes.count()); + result.reserve(d->persistent.indexes.size()); for (auto *data : qAsConst(d->persistent.indexes)) result.append(data->index); return result; diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp index 99324a0cd5..023587e39a 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.cpp +++ b/src/corelib/itemmodels/qabstractproxymodel.cpp @@ -443,7 +443,7 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const { Q_D(const QAbstractProxyModel); QModelIndexList list; - list.reserve(indexes.count()); + list.reserve(indexes.size()); for (const QModelIndex &index : indexes) list << mapToSource(index); return d->model->mimeData(list); diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index 7ef0bbc7a7..44cf28b47a 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -315,7 +315,7 @@ QMimeData *QConcatenateTablesProxyModel::mimeData(const QModelIndexList &indexes Q_ASSERT(checkIndex(firstIndex, CheckIndexOption::IndexIsValid)); const auto result = d->sourceModelForRow(firstIndex.row()); QModelIndexList sourceIndexes; - sourceIndexes.reserve(indexes.count()); + sourceIndexes.reserve(indexes.size()); for (const QModelIndex &index : indexes) { const QModelIndex sourceIndex = mapToSource(index); Q_ASSERT(sourceIndex.model() == result.sourceModel); // see documentation above @@ -688,7 +688,7 @@ void QConcatenateTablesProxyModelPrivate::updateColumnCount() int QConcatenateTablesProxyModelPrivate::columnCountAfterChange(const QAbstractItemModel *model, int newCount) const { int newColumnCount = 0; - for (int i = 0; i < m_models.count(); ++i) { + for (int i = 0; i < m_models.size(); ++i) { const QAbstractItemModel *mod = m_models.at(i); const int colCount = mod == model ? newCount : mod->columnCount(); if (i == 0) diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index b610298cbb..cc0730d769 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -144,7 +144,7 @@ QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection& QItemSelection::const_iterator it = selection.constBegin(); const QItemSelection::const_iterator end = selection.constEnd(); - proxySelection.reserve(selection.count()); + proxySelection.reserve(selection.size()); for ( ; it != end; ++it) { Q_ASSERT(it->model() == d->model); const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight())); @@ -167,7 +167,7 @@ QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& s QItemSelection::const_iterator it = selection.constBegin(); const QItemSelection::const_iterator end = selection.constEnd(); - sourceSelection.reserve(selection.count()); + sourceSelection.reserve(selection.size()); for ( ; it != end; ++it) { Q_ASSERT(it->model() == this); const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight())); @@ -203,7 +203,7 @@ QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, c QModelIndexList::const_iterator it = sourceList.constBegin(); const QModelIndexList::const_iterator end = sourceList.constEnd(); QModelIndexList proxyList; - proxyList.reserve(sourceList.count()); + proxyList.reserve(sourceList.size()); for ( ; it != end; ++it) proxyList.append(mapFromSource(*it)); return proxyList; diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 7da3a9b003..696817e971 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -466,15 +466,15 @@ void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::Sel if (!range.isValid()) continue; newSelection.push_back(range); - for (int t = 0; t < count(); ++t) { + for (int t = 0; t < size(); ++t) { if (range.intersects(at(t))) intersections.append(at(t).intersected(range)); } } // Split the old (and new) ranges using the intersections - for (int i = 0; i < intersections.count(); ++i) { // for each intersection - for (int t = 0; t < count();) { // splitt each old range + for (int i = 0; i < intersections.size(); ++i) { // for each intersection + for (int t = 0; t < size();) { // splitt each old range if (at(t).intersects(intersections.at(i))) { split(at(t), intersections.at(i), this); removeAt(t); @@ -483,7 +483,7 @@ void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::Sel } } // only split newSelection if Toggle is specified - for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.count();) { + for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.size();) { if (newSelection.at(n).intersects(intersections.at(i))) { split(newSelection.at(n), intersections.at(i), &newSelection); newSelection.removeAt(n); @@ -613,7 +613,7 @@ QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection QItemSelection expanded; if (command & QItemSelectionModel::Rows) { - for (int i = 0; i < selection.count(); ++i) { + for (int i = 0; i < selection.size(); ++i) { QModelIndex parent = selection.at(i).parent(); int colCount = model->columnCount(parent); QModelIndex tl = model->index(selection.at(i).top(), 0, parent); @@ -623,7 +623,7 @@ QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection } } if (command & QItemSelectionModel::Columns) { - for (int i = 0; i < selection.count(); ++i) { + for (int i = 0; i < selection.size(); ++i) { QModelIndex parent = selection.at(i).parent(); int rowCount = model->rowCount(parent); QModelIndex tl = model->index(0, selection.at(i).left(), parent); @@ -838,7 +838,7 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged(const QList<QPersiste // optimization for when all indexes are selected // (only if there is lots of items (1000) because this is not entirely correct) - if (ranges.isEmpty() && currentSelection.count() == 1) { + if (ranges.isEmpty() && currentSelection.size() == 1) { QItemSelectionRange range = currentSelection.constFirst(); QModelIndex parent = range.parent(); tableRowCount = model->rowCount(parent); @@ -878,7 +878,7 @@ static QItemSelection mergeRowLengths(const QList<QPair<QPersistentModelIndex, u QItemSelection result; int i = 0; - while (i < rowLengths.count()) { + while (i < rowLengths.size()) { const QPersistentModelIndex &tl = rowLengths.at(i).first; if (!tl.isValid()) { ++i; @@ -886,7 +886,7 @@ static QItemSelection mergeRowLengths(const QList<QPair<QPersistentModelIndex, u } QPersistentModelIndex br = tl; const uint length = rowLengths.at(i).second; - while (++i < rowLengths.count()) { + while (++i < rowLengths.size()) { const QPersistentModelIndex &next = rowLengths.at(i).first; if (!next.isValid()) continue; @@ -916,7 +916,7 @@ static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes) QItemSelection colSpans; // merge columns int i = 0; - while (i < indexes.count()) { + while (i < indexes.size()) { const QPersistentModelIndex &tl = indexes.at(i); if (!tl.isValid()) { ++i; @@ -926,7 +926,7 @@ static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes) QModelIndex brParent = br.parent(); int brRow = br.row(); int brColumn = br.column(); - while (++i < indexes.count()) { + while (++i < indexes.size()) { const QPersistentModelIndex &next = indexes.at(i); if (!next.isValid()) continue; @@ -949,11 +949,11 @@ static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes) // merge rows QItemSelection rowSpans; i = 0; - while (i < colSpans.count()) { + while (i < colSpans.size()) { QModelIndex tl = colSpans.at(i).topLeft(); QModelIndex br = colSpans.at(i).bottomRight(); QModelIndex prevTl = tl; - while (++i < colSpans.count()) { + while (++i < colSpans.size()) { QModelIndex nextTl = colSpans.at(i).topLeft(); QModelIndex nextBr = colSpans.at(i).bottomRight(); @@ -1362,7 +1362,7 @@ void QItemSelectionModel::reset() void QItemSelectionModel::clearSelection() { Q_D(QItemSelectionModel); - if (d->ranges.count() == 0 && d->currentSelection.count() == 0) + if (d->ranges.size() == 0 && d->currentSelection.size() == 0) return; select(QItemSelection(), Clear); @@ -1433,7 +1433,7 @@ bool QItemSelectionModel::isSelected(const QModelIndex &index) const } // check currentSelection - if (d->currentSelection.count()) { + if (d->currentSelection.size()) { if ((d->currentCommand & Deselect) && selected) selected = !d->currentSelection.contains(index); else if (d->currentCommand & Toggle) @@ -1468,8 +1468,8 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons return false; // return false if row exist in currentSelection (Deselect) - if (d->currentCommand & Deselect && d->currentSelection.count()) { - for (int i=0; i<d->currentSelection.count(); ++i) { + if (d->currentCommand & Deselect && d->currentSelection.size()) { + for (int i=0; i<d->currentSelection.size(); ++i) { if (d->currentSelection.at(i).parent() == parent && row >= d->currentSelection.at(i).top() && row <= d->currentSelection.at(i).bottom()) @@ -1478,11 +1478,11 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons } // return false if ranges in both currentSelection and ranges // intersect and have the same row contained - if (d->currentCommand & Toggle && d->currentSelection.count()) { - for (int i=0; i<d->currentSelection.count(); ++i) + if (d->currentCommand & Toggle && d->currentSelection.size()) { + for (int i=0; i<d->currentSelection.size(); ++i) if (d->currentSelection.at(i).top() <= row && d->currentSelection.at(i).bottom() >= row) - for (int j=0; j<d->ranges.count(); ++j) + for (int j=0; j<d->ranges.size(); ++j) if (d->ranges.at(j).top() <= row && d->ranges.at(j).bottom() >= row && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) return false; @@ -1497,7 +1497,7 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons // add ranges and currentSelection and check through them all QList<QItemSelectionRange>::const_iterator it; QList<QItemSelectionRange> joined = d->ranges; - if (d->currentSelection.count()) + if (d->currentSelection.size()) joined += d->currentSelection; for (int column = 0; column < colCount; ++column) { if (!isSelectable(row, column)) { @@ -1542,8 +1542,8 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent return false; // return false if column exist in currentSelection (Deselect) - if (d->currentCommand & Deselect && d->currentSelection.count()) { - for (int i = 0; i < d->currentSelection.count(); ++i) { + if (d->currentCommand & Deselect && d->currentSelection.size()) { + for (int i = 0; i < d->currentSelection.size(); ++i) { if (d->currentSelection.at(i).parent() == parent && column >= d->currentSelection.at(i).left() && column <= d->currentSelection.at(i).right()) @@ -1552,11 +1552,11 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent } // return false if ranges in both currentSelection and the selection model // intersect and have the same column contained - if (d->currentCommand & Toggle && d->currentSelection.count()) { - for (int i = 0; i < d->currentSelection.count(); ++i) { + if (d->currentCommand & Toggle && d->currentSelection.size()) { + for (int i = 0; i < d->currentSelection.size(); ++i) { if (d->currentSelection.at(i).left() <= column && d->currentSelection.at(i).right() >= column) { - for (int j = 0; j < d->ranges.count(); ++j) { + for (int j = 0; j < d->ranges.size(); ++j) { if (d->ranges.at(j).left() <= column && d->ranges.at(j).right() >= column && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) { return false; @@ -1575,7 +1575,7 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent // add ranges and currentSelection and check through them all QList<QItemSelectionRange>::const_iterator it; QList<QItemSelectionRange> joined = d->ranges; - if (d->currentSelection.count()) + if (d->currentSelection.size()) joined += d->currentSelection; for (int row = 0; row < rowCount; ++row) { if (!isSelectable(row, column)) { @@ -1759,7 +1759,7 @@ QModelIndexList QItemSelectionModel::selectedRows(int column) const QDuplicateTracker<RowOrColumnDefinition> rowsSeen; const QItemSelection ranges = selection(); - for (int i = 0; i < ranges.count(); ++i) { + for (int i = 0; i < ranges.size(); ++i) { const QItemSelectionRange &range = ranges.at(i); QModelIndex parent = range.parent(); for (int row = range.top(); row <= range.bottom(); row++) { @@ -1788,7 +1788,7 @@ QModelIndexList QItemSelectionModel::selectedColumns(int row) const QDuplicateTracker<RowOrColumnDefinition> columnsSeen; const QItemSelection ranges = selection(); - for (int i = 0; i < ranges.count(); ++i) { + for (int i = 0; i < ranges.size(); ++i) { const QItemSelectionRange &range = ranges.at(i); QModelIndex parent = range.parent(); for (int column = range.left(); column <= range.right(); column++) { @@ -1911,9 +1911,9 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio // remove equal ranges bool advance; - for (int o = 0; o < deselected.count(); ++o) { + for (int o = 0; o < deselected.size(); ++o) { advance = true; - for (int s = 0; s < selected.count() && o < deselected.count();) { + for (int s = 0; s < selected.size() && o < deselected.size();) { if (deselected.at(o) == selected.at(s)) { deselected.removeAt(o); selected.removeAt(s); @@ -1928,17 +1928,17 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio // find intersections QItemSelection intersections; - for (int o = 0; o < deselected.count(); ++o) { - for (int s = 0; s < selected.count(); ++s) { + for (int o = 0; o < deselected.size(); ++o) { + for (int s = 0; s < selected.size(); ++s) { if (deselected.at(o).intersects(selected.at(s))) intersections.append(deselected.at(o).intersected(selected.at(s))); } } // compare remaining ranges with intersections and split them to find deselected and selected - for (int i = 0; i < intersections.count(); ++i) { + for (int i = 0; i < intersections.size(); ++i) { // split deselected - for (int o = 0; o < deselected.count();) { + for (int o = 0; o < deselected.size();) { if (deselected.at(o).intersects(intersections.at(i))) { QItemSelection::split(deselected.at(o), intersections.at(i), &deselected); deselected.removeAt(o); @@ -1947,7 +1947,7 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio } } // split selected - for (int s = 0; s < selected.count();) { + for (int s = 0; s < selected.size();) { if (selected.at(s).intersects(intersections.at(i))) { QItemSelection::split(selected.at(s), intersections.at(i), &selected); selected.removeAt(s); diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 27cf624c51..599aae6a15 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -959,12 +959,12 @@ void QSortFilterProxyModelPrivate::source_items_inserted( it = create_mapping(source_parent); Mapping *m = it.value(); QModelIndex proxy_parent = q->mapFromSource(source_parent); - if (m->source_rows.count() > 0) { - q->beginInsertRows(proxy_parent, 0, m->source_rows.count() - 1); + if (m->source_rows.size() > 0) { + q->beginInsertRows(proxy_parent, 0, m->source_rows.size() - 1); q->endInsertRows(); } - if (m->source_columns.count() > 0) { - q->beginInsertColumns(proxy_parent, 0, m->source_columns.count() - 1); + if (m->source_columns.size() > 0) { + q->beginInsertColumns(proxy_parent, 0, m->source_columns.size() - 1); q->endInsertColumns(); } return; @@ -1190,7 +1190,7 @@ void QSortFilterProxyModelPrivate::proxy_item_range( { proxy_low = INT_MAX; proxy_high = INT_MIN; - for (int i = 0; i < source_items.count(); ++i) { + for (int i = 0; i < source_items.size(); ++i) { int proxy_item = source_to_proxy.at(source_items.at(i)); Q_ASSERT(proxy_item != -1); if (proxy_item < proxy_low) @@ -1223,7 +1223,7 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes() con { Q_Q(const QSortFilterProxyModel); QModelIndexPairList source_indexes; - source_indexes.reserve(persistent.indexes.count()); + source_indexes.reserve(persistent.indexes.size()); for (const QPersistentModelIndexData *data : qAsConst(persistent.indexes)) { const QModelIndex &proxy_index = data->index; QModelIndex source_index = q->mapToSource(proxy_index); @@ -1243,7 +1243,7 @@ void QSortFilterProxyModelPrivate::update_persistent_indexes( { Q_Q(QSortFilterProxyModel); QModelIndexList from, to; - const int numSourceIndexes = source_indexes.count(); + const int numSourceIndexes = source_indexes.size(); from.reserve(numSourceIndexes); to.reserve(numSourceIndexes); for (const auto &indexPair : source_indexes) { @@ -1327,7 +1327,7 @@ QSet<int> QSortFilterProxyModelPrivate::handle_filter_changed( Q_Q(QSortFilterProxyModel); // Figure out which mapped items to remove QList<int> source_items_remove; - for (int i = 0; i < proxy_to_source.count(); ++i) { + for (int i = 0; i < proxy_to_source.size(); ++i) { const int source_item = proxy_to_source.at(i); if ((orient == Qt::Vertical) ? !filterAcceptsRowInternal(source_item, source_parent) @@ -1435,7 +1435,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc QList<int> source_rows_insert; QList<int> source_rows_change; QList<int> source_rows_resort; - int end = qMin(source_bottom_right.row(), m->proxy_rows.count() - 1); + int end = qMin(source_bottom_right.row(), m->proxy_rows.size() - 1); for (int source_row = source_top_left.row(); source_row <= end; ++source_row) { if (dynamic_sortfilter && !change_in_unmapped_parent) { if (m->proxy_rows.at(source_row) != -1) { @@ -2155,7 +2155,7 @@ QModelIndex QSortFilterProxyModel::index(int row, int column, const QModelIndex QModelIndex source_parent = mapToSource(parent); // parent is already mapped at this point IndexMap::const_iterator it = d->create_mapping(source_parent); // but make sure that the children are mapped - if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column) + if (it.value()->source_rows.size() <= row || it.value()->source_columns.size() <= column) return QModelIndex(); return d->create_index(row, column, it); @@ -2186,7 +2186,7 @@ QModelIndex QSortFilterProxyModel::sibling(int row, int column, const QModelInde return QModelIndex(); const IndexMap::const_iterator it = d->index_to_iterator(idx); - if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column) + if (it.value()->source_rows.size() <= row || it.value()->source_columns.size() <= column) return QModelIndex(); return d->create_index(row, column, it); @@ -2202,7 +2202,7 @@ int QSortFilterProxyModel::rowCount(const QModelIndex &parent) const if (parent.isValid() && !source_parent.isValid()) return 0; IndexMap::const_iterator it = d->create_mapping(source_parent); - return it.value()->source_rows.count(); + return it.value()->source_rows.size(); } /*! @@ -2215,7 +2215,7 @@ int QSortFilterProxyModel::columnCount(const QModelIndex &parent) const if (parent.isValid() && !source_parent.isValid()) return 0; IndexMap::const_iterator it = d->create_mapping(source_parent); - return it.value()->source_columns.count(); + return it.value()->source_columns.size(); } /*! @@ -2234,7 +2234,7 @@ bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const return true; //we assume we might have children that can be fetched QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - return m->source_rows.count() != 0 && m->source_columns.count() != 0; + return m->source_rows.size() != 0 && m->source_columns.size() != 0; } /*! @@ -2268,15 +2268,15 @@ QVariant QSortFilterProxyModel::headerData(int section, Qt::Orientation orientat { Q_D(const QSortFilterProxyModel); IndexMap::const_iterator it = d->create_mapping(QModelIndex()); - if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) + if (it.value()->source_rows.size() * it.value()->source_columns.size() > 0) return QAbstractProxyModel::headerData(section, orientation, role); int source_section; if (orientation == Qt::Vertical) { - if (section < 0 || section >= it.value()->source_rows.count()) + if (section < 0 || section >= it.value()->source_rows.size()) return QVariant(); source_section = it.value()->source_rows.at(section); } else { - if (section < 0 || section >= it.value()->source_columns.count()) + if (section < 0 || section >= it.value()->source_columns.size()) return QVariant(); source_section = it.value()->source_columns.at(section); } @@ -2291,15 +2291,15 @@ bool QSortFilterProxyModel::setHeaderData(int section, Qt::Orientation orientati { Q_D(QSortFilterProxyModel); IndexMap::const_iterator it = d->create_mapping(QModelIndex()); - if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) + if (it.value()->source_rows.size() * it.value()->source_columns.size() > 0) return QAbstractProxyModel::setHeaderData(section, orientation, value, role); int source_section; if (orientation == Qt::Vertical) { - if (section < 0 || section >= it.value()->source_rows.count()) + if (section < 0 || section >= it.value()->source_rows.size()) return false; source_section = it.value()->source_rows.at(section); } else { - if (section < 0 || section >= it.value()->source_columns.count()) + if (section < 0 || section >= it.value()->source_columns.size()) return false; source_section = it.value()->source_columns.at(section); } @@ -2313,7 +2313,7 @@ QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const { Q_D(const QSortFilterProxyModel); QModelIndexList source_indexes; - source_indexes.reserve(indexes.count()); + source_indexes.reserve(indexes.size()); for (const QModelIndex &idx : indexes) source_indexes << mapToSource(idx); return d->model->mimeData(source_indexes); @@ -2359,10 +2359,10 @@ bool QSortFilterProxyModel::insertRows(int row, int count, const QModelIndex &pa if (parent.isValid() && !source_parent.isValid()) return false; QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (row > m->source_rows.count()) + if (row > m->source_rows.size()) return false; - int source_row = (row >= m->source_rows.count() - ? m->proxy_rows.count() + int source_row = (row >= m->source_rows.size() + ? m->proxy_rows.size() : m->source_rows.at(row)); return d->model->insertRows(source_row, count, source_parent); } @@ -2379,10 +2379,10 @@ bool QSortFilterProxyModel::insertColumns(int column, int count, const QModelInd if (parent.isValid() && !source_parent.isValid()) return false; QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (column > m->source_columns.count()) + if (column > m->source_columns.size()) return false; - int source_column = (column >= m->source_columns.count() - ? m->proxy_columns.count() + int source_column = (column >= m->source_columns.size() + ? m->proxy_columns.size() : m->source_columns.at(column)); return d->model->insertColumns(source_column, count, source_parent); } @@ -2399,10 +2399,10 @@ bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &pa if (parent.isValid() && !source_parent.isValid()) return false; QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (row + count > m->source_rows.count()) + if (row + count > m->source_rows.size()) return false; if ((count == 1) - || ((d->source_sort_column < 0) && (m->proxy_rows.count() == m->source_rows.count()))) { + || ((d->source_sort_column < 0) && (m->proxy_rows.size() == m->source_rows.size()))) { int source_row = m->source_rows.at(row); return d->model->removeRows(source_row, count, source_parent); } @@ -2414,7 +2414,7 @@ bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &pa rows.append(m->source_rows.at(i)); std::sort(rows.begin(), rows.end()); - int pos = rows.count() - 1; + int pos = rows.size() - 1; bool ok = true; while (pos >= 0) { const int source_end = rows.at(pos--); @@ -2441,9 +2441,9 @@ bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelInd if (parent.isValid() && !source_parent.isValid()) return false; QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (column + count > m->source_columns.count()) + if (column + count > m->source_columns.size()) return false; - if ((count == 1) || (m->proxy_columns.count() == m->source_columns.count())) { + if ((count == 1) || (m->proxy_columns.size() == m->source_columns.size())) { int source_column = m->source_columns.at(column); return d->model->removeColumns(source_column, count, source_parent); } @@ -2453,7 +2453,7 @@ bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelInd for (int i = column; i < column + count; ++i) columns.append(m->source_columns.at(i)); - int pos = columns.count() - 1; + int pos = columns.size() - 1; bool ok = true; while (pos >= 0) { const int source_end = columns.at(pos--); diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index 8d409f46a0..002f500263 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -86,7 +86,7 @@ int QStringListModel::rowCount(const QModelIndex &parent) const if (parent.isValid()) return 0; - return lst.count(); + return lst.size(); } /*! @@ -94,7 +94,7 @@ int QStringListModel::rowCount(const QModelIndex &parent) const */ QModelIndex QStringListModel::sibling(int row, int column, const QModelIndex &idx) const { - if (!idx.isValid() || column != 0 || row >= lst.count() || row < 0) + if (!idx.isValid() || column != 0 || row >= lst.size() || row < 0) return QModelIndex(); return createIndex(row, 0); @@ -310,7 +310,7 @@ void QStringListModel::sort(int, Qt::SortOrder order) emit layoutAboutToBeChanged(QList<QPersistentModelIndex>(), VerticalSortHint); QList<QPair<QString, int>> list; - const int lstCount = lst.count(); + const int lstCount = lst.size(); list.reserve(lstCount); for (int i = 0; i < lstCount; ++i) list.append(QPair<QString, int>(lst.at(i), i)); @@ -329,7 +329,7 @@ void QStringListModel::sort(int, Qt::SortOrder order) QModelIndexList oldList = persistentIndexList(); QModelIndexList newList; - const int numOldIndexes = oldList.count(); + const int numOldIndexes = oldList.size(); newList.reserve(numOldIndexes); for (int i = 0; i < numOldIndexes; ++i) newList.append(index(forwarding.at(oldList.at(i).row()), 0)); diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 84a688a9e4..3001e3269b 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -382,7 +382,7 @@ void QAbstractEventDispatcher::installNativeEventFilter(QAbstractNativeEventFilt void QAbstractEventDispatcher::removeNativeEventFilter(QAbstractNativeEventFilter *filter) { Q_D(QAbstractEventDispatcher); - for (int i = 0; i < d->eventFilters.count(); ++i) { + for (int i = 0; i < d->eventFilters.size(); ++i) { if (d->eventFilters.at(i) == filter) { d->eventFilters[i] = nullptr; break; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4d69ca9a17..6142f040d6 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -783,7 +783,7 @@ void QCoreApplicationPrivate::init() // have been removed. Once the original list is exhausted we know all the remaining // items have been added. QStringList newPaths(q->libraryPaths()); - for (qsizetype i = manualPaths->length(), j = appPaths->length(); i > 0 || j > 0; qt_noop()) { + for (qsizetype i = manualPaths->size(), j = appPaths->size(); i > 0 || j > 0; qt_noop()) { if (--j < 0) { newPaths.prepend((*manualPaths)[--i]); } else if (--i < 0) { @@ -2138,12 +2138,12 @@ static void replacePercentN(QString *result, int n) qsizetype len = 0; while ((percentPos = result->indexOf(u'%', percentPos + len)) != -1) { len = 1; - if (percentPos + len == result->length()) + if (percentPos + len == result->size()) break; QString fmt; if (result->at(percentPos + len) == u'L') { ++len; - if (percentPos + len == result->length()) + if (percentPos + len == result->size()) break; fmt = "%L1"_L1; } else { @@ -2153,7 +2153,7 @@ static void replacePercentN(QString *result, int n) fmt = fmt.arg(n); ++len; result->replace(percentPos, len, fmt); - len = fmt.length(); + len = fmt.size(); } } } diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index b5bd21c8ab..c644dd35d8 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -41,7 +41,7 @@ static gboolean socketNotifierSourceCheck(GSource *source) GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source); bool pending = false; - for (int i = 0; !pending && i < src->pollfds.count(); ++i) { + for (int i = 0; !pending && i < src->pollfds.size(); ++i) { GPollFDWithQSocketNotifier *p = src->pollfds.at(i); if (p->pollfd.revents & G_IO_NVAL) { @@ -65,7 +65,7 @@ static gboolean socketNotifierSourceDispatch(GSource *source, GSourceFunc, gpoin QEvent event(QEvent::SockAct); GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source); - for (src->activeNotifierPos = 0; src->activeNotifierPos < src->pollfds.count(); + for (src->activeNotifierPos = 0; src->activeNotifierPos < src->pollfds.size(); ++src->activeNotifierPos) { GPollFDWithQSocketNotifier *p = src->pollfds.at(src->activeNotifierPos); @@ -348,7 +348,7 @@ QEventDispatcherGlib::~QEventDispatcherGlib() d->idleTimerSource = nullptr; // destroy socket notifier source - for (int i = 0; i < d->socketNotifierSource->pollfds.count(); ++i) { + for (int i = 0; i < d->socketNotifierSource->pollfds.size(); ++i) { GPollFDWithQSocketNotifier *p = d->socketNotifierSource->pollfds[i]; g_source_remove_poll(&d->socketNotifierSource->source, &p->pollfd); delete p; @@ -458,7 +458,7 @@ void QEventDispatcherGlib::unregisterSocketNotifier(QSocketNotifier *notifier) Q_D(QEventDispatcherGlib); - for (int i = 0; i < d->socketNotifierSource->pollfds.count(); ++i) { + for (int i = 0; i < d->socketNotifierSource->pollfds.size(); ++i) { GPollFDWithQSocketNotifier *p = d->socketNotifierSource->pollfds.at(i); if (p->socketNotifier == notifier) { // found it diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index c73fd425c2..fe8c25f1e5 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -227,7 +227,7 @@ QObject *QMetaObject::newInstance(QGenericArgument val0, constructorName.remove(0, idx+1); // remove qualified part } QVarLengthArray<char, 512> sig; - sig.append(constructorName.constData(), constructorName.length()); + sig.append(constructorName.constData(), constructorName.size()); sig.append('('); enum { MaximumParamCount = 10 }; diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 6319e6eafe..38ffd95992 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1090,7 +1090,7 @@ static const struct : QMetaTypeModuleHelper #endif QMETATYPE_CONVERTER(QString, QByteArray, result = QString::fromUtf8(source); return true;); QMETATYPE_CONVERTER(QString, QStringList, - return (source.count() == 1) ? (result = source.at(0), true) : false; + return (source.size() == 1) ? (result = source.at(0), true) : false; ); #ifndef QT_BOOTSTRAPPED QMETATYPE_CONVERTER(QString, QUrl, result = source.toString(); return true;); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ac5e839eb2..b687f13b85 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2155,7 +2155,7 @@ void QObjectPrivate::deleteChildren() // delete children objects // don't use qDeleteAll as the destructor of the child might // delete siblings - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { currentChildBeingDeleted = children.at(i); children[i] = nullptr; delete currentChildBeingDeleted; @@ -2303,7 +2303,7 @@ void QObject::removeEventFilter(QObject *obj) { Q_D(QObject); if (d->extraData) { - for (int i = 0; i < d->extraData->eventFilters.count(); ++i) { + for (int i = 0; i < d->extraData->eventFilters.size(); ++i) { if (d->extraData->eventFilters.at(i) == obj) d->extraData->eventFilters[i] = nullptr; } @@ -3684,7 +3684,7 @@ void QMetaObject::connectSlotsByName(QObject *o) // ...we check each object in our list, ... bool foundIt = false; - for (int j = 0; j < list.count(); ++j) { + for (int j = 0; j < list.size(); ++j) { const QObject *co = list.at(j); const QByteArray coName = co->objectName().toLatin1(); diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 48ce893988..34225a809d 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -390,7 +390,7 @@ int QTimerInfoList::timerRemainingTime(int timerId) repairTimersIfNeeded(); timespec tm = {0, 0}; - for (int i = 0; i < count(); ++i) { + for (int i = 0; i < size(); ++i) { QTimerInfo *t = at(i); if (t->id == timerId) { if (currentTime < t->timeout) { @@ -475,7 +475,7 @@ void QTimerInfoList::registerTimer(int timerId, qint64 interval, Qt::TimerType t bool QTimerInfoList::unregisterTimer(int timerId) { // set timer inactive - for (int i = 0; i < count(); ++i) { + for (int i = 0; i < size(); ++i) { QTimerInfo *t = at(i); if (t->id == timerId) { // found it @@ -496,7 +496,7 @@ bool QTimerInfoList::unregisterTimers(QObject *object) { if (isEmpty()) return false; - for (int i = 0; i < count(); ++i) { + for (int i = 0; i < size(); ++i) { QTimerInfo *t = at(i); if (t->obj == object) { // object found @@ -516,7 +516,7 @@ bool QTimerInfoList::unregisterTimers(QObject *object) QList<QAbstractEventDispatcher::TimerInfo> QTimerInfoList::registeredTimers(QObject *object) const { QList<QAbstractEventDispatcher::TimerInfo> list; - for (int i = 0; i < count(); ++i) { + for (int i = 0; i < size(); ++i) { const QTimerInfo * const t = at(i); if (t->obj == object) { list << QAbstractEventDispatcher::TimerInfo(t->id, diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index f6f7ec12d1..85e69ea2a1 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -449,7 +449,7 @@ bool QTranslator::load(const QString & filename, const QString & directory, QString prefix; if (QFileInfo(filename).isRelative()) { prefix = directory; - if (prefix.length() && !prefix.endsWith(u'/')) + if (prefix.size() && !prefix.endsWith(u'/')) prefix += u'/'; } @@ -472,7 +472,7 @@ bool QTranslator::load(const QString & filename, const QString & directory, break; int rightmost = 0; - for (int i = 0; i < (int)delims.length(); i++) { + for (int i = 0; i < (int)delims.size(); i++) { int k = fname.lastIndexOf(delims[i]); if (k > rightmost) rightmost = k; @@ -914,7 +914,7 @@ end: if (!tn) return QString(); QString str(tn_length / 2, Qt::Uninitialized); - qFromBigEndian<ushort>(tn, str.length(), str.data()); + qFromBigEndian<ushort>(tn, str.size(), str.data()); return str; } diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 6d6b322229..d89d3e9a83 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -357,7 +357,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa // Pass 1) Try to match on the file name QMimeGlobMatchResult candidatesByName = findByFileName(fileName); - if (candidatesByName.m_allMatchingMimeTypes.count() == 1) { + if (candidatesByName.m_allMatchingMimeTypes.size() == 1) { const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) return mime; @@ -399,7 +399,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa } } - if (candidatesByName.m_allMatchingMimeTypes.count() > 1) { + if (candidatesByName.m_allMatchingMimeTypes.size() > 1) { candidatesByName.m_matchingMimeTypes.sort(); // make it deterministic const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) @@ -652,7 +652,7 @@ QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) co const QStringList matches = d->mimeTypeForFileName(fileName); QList<QMimeType> mimes; - mimes.reserve(matches.count()); + mimes.reserve(matches.size()); for (const QString &mime : matches) mimes.append(d->mimeTypeForName(mime)); return mimes; diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index f991d15b6c..381b635b90 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -34,9 +34,9 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q bool replace = weight > m_weight; if (!replace) { // Compare the length of the match - if (pattern.length() < m_matchingPatternLength) + if (pattern.size() < m_matchingPatternLength) return; // too short, ignore - else if (pattern.length() > m_matchingPatternLength) { + else if (pattern.size() > m_matchingPatternLength) { // longer: clear any previous match (like *.bz2, when pattern is *.tar.bz2) replace = true; } @@ -44,7 +44,7 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q if (replace) { m_matchingMimeTypes.clear(); // remember the new "longer" length - m_matchingPatternLength = pattern.length(); + m_matchingPatternLength = pattern.size(); m_weight = weight; } if (!m_matchingMimeTypes.contains(mimeType)) { @@ -59,7 +59,7 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString &pattern) const { - const int patternLength = pattern.length(); + const int patternLength = pattern.size(); if (!patternLength) return OtherPattern; @@ -108,10 +108,10 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFileName) const const QString fileName = m_caseSensitivity == Qt::CaseInsensitive ? inputFileName.toLower() : inputFileName; - const int patternLength = m_pattern.length(); + const int patternLength = m_pattern.size(); if (!patternLength) return false; - const int fileNameLength = fileName.length(); + const int fileNameLength = fileName.size(); switch (m_patternType) { case SuffixPattern: { @@ -166,7 +166,7 @@ static bool isSimplePattern(const QString &pattern) { // starts with "*.", has no other '*' return pattern.lastIndexOf(u'*') == 0 - && pattern.length() > 1 + && pattern.size() > 1 && pattern.at(1) == u'.' // (other dots are OK, like *.tar.bz2) // and contains no other special character && !pattern.contains(u'?') @@ -229,7 +229,7 @@ void QMimeGlobPatternList::match(QMimeGlobMatchResult &result, const QMimeGlobPattern &glob = *it; if (glob.matchFileName(fileName)) { const QString pattern = glob.pattern(); - const int suffixLen = isSimplePattern(pattern) ? pattern.length() - 2 : 0; + const int suffixLen = isSimplePattern(pattern) ? pattern.size() - 2 : 0; result.addMatch(glob.mimeType(), glob.weight(), pattern, suffixLen); } } @@ -244,7 +244,7 @@ void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatch // (which is most of them, so this optimization is definitely worth it) const int lastDot = fileName.lastIndexOf(u'.'); if (lastDot != -1) { // if no '.', skip the extension lookup - const int ext_len = fileName.length() - lastDot - 1; + const int ext_len = fileName.size() - lastDot - 1; const QString simpleExtension = fileName.right(ext_len).toLower(); // (toLower because fast patterns are always case-insensitive and saved as lowercase) diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index cbb1ccd527..8ab07c00d1 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -219,9 +219,9 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset); const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset); const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4); - matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false); + matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.size() - 1, false); if (result.m_matchingMimeTypes.isEmpty()) - matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true); + matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.size() - 1, true); } // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*") if (result.m_matchingMimeTypes.isEmpty()) @@ -448,7 +448,7 @@ void QMimeBinaryProvider::addAllMimeTypes(QList<QMimeType> &result) { loadMimeTypeList(); if (result.isEmpty()) { - result.reserve(m_mimetypeNames.count()); + result.reserve(m_mimetypeNames.size()); for (const QString &name : qAsConst(m_mimetypeNames)) result.append(mimeTypeForNameUnchecked(name)); } else { @@ -700,7 +700,7 @@ void QMimeXMLProvider::ensureLoaded() const QString packageDir = m_directory + QStringLiteral("/packages"); QDir dir(packageDir); const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); - allFiles.reserve(files.count()); + allFiles.reserve(files.size()); for (const QString &xmlFile : files) allFiles.append(packageDir + u'/' + xmlFile); diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index c578f3cad0..16b6d460eb 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -413,7 +413,7 @@ QStringList QMimeType::suffixes() const for (const QString &pattern : qAsConst(d->globPatterns)) { // Not a simple suffix if it looks like: README or *. or *.* or *.JP*G or *.JP? if (pattern.startsWith("*."_L1) && - pattern.length() > 2 && + pattern.size() > 2 && pattern.indexOf(u'*', 2) < 0 && pattern.indexOf(u'?', 2) < 0) { const QString suffix = pattern.mid(2); result.append(suffix); diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp index 65edd3a941..a45158bcb0 100644 --- a/src/corelib/serialization/qcborstreamreader.cpp +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -1309,7 +1309,7 @@ QCborStreamReader::StringResult<QString> QCborStreamReader::_readString_helper() if (r.status == Error) { result.data.clear(); } else { - Q_ASSERT(r.data == result.data.length()); + Q_ASSERT(r.data == result.data.size()); if (r.status == EndOfString && lastError() == QCborError::NoError) preparse(); } @@ -1341,7 +1341,7 @@ QCborStreamReader::StringResult<QByteArray> QCborStreamReader::_readByteArray_he if (r.status == Error) { result.data.clear(); } else { - Q_ASSERT(r.data == result.data.length()); + Q_ASSERT(r.data == result.data.size()); if (r.status == EndOfString && lastError() == QCborError::NoError) preparse(); } diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp index 167b6a3a77..85e73af06b 100644 --- a/src/corelib/serialization/qjsonarray.cpp +++ b/src/corelib/serialization/qjsonarray.cpp @@ -339,7 +339,7 @@ void QJsonArray::append(const QJsonValue &value) */ void QJsonArray::removeAt(qsizetype i) { - if (!a || i < 0 || i >= a->elements.length()) + if (!a || i < 0 || i >= a->elements.size()) return; detach(); a->removeAt(i); @@ -375,7 +375,7 @@ void QJsonArray::removeAt(qsizetype i) */ QJsonValue QJsonArray::takeAt(qsizetype i) { - if (!a || i < 0 || i >= a->elements.length()) + if (!a || i < 0 || i >= a->elements.size()) return QJsonValue(QJsonValue::Undefined); detach(); @@ -394,11 +394,11 @@ QJsonValue QJsonArray::takeAt(qsizetype i) void QJsonArray::insert(qsizetype i, const QJsonValue &value) { if (a) - detach(a->elements.length() + 1); + detach(a->elements.size() + 1); else a = new QCborContainerPrivate; - Q_ASSERT (i >= 0 && i <= a->elements.length()); + Q_ASSERT (i >= 0 && i <= a->elements.size()); a->insertAt(i, value.type() == QJsonValue::Undefined ? QCborValue(nullptr) : QCborValue::fromJsonValue(value)); } @@ -429,7 +429,7 @@ void QJsonArray::insert(qsizetype i, const QJsonValue &value) */ void QJsonArray::replace(qsizetype i, const QJsonValue &value) { - Q_ASSERT (a && i >= 0 && i < a->elements.length()); + Q_ASSERT (a && i >= 0 && i < a->elements.size()); detach(); a->replaceAt(i, QCborValue::fromJsonValue(value)); } @@ -463,7 +463,7 @@ bool QJsonArray::contains(const QJsonValue &value) const */ QJsonValueRef QJsonArray::operator [](qsizetype i) { - Q_ASSERT(a && i >= 0 && i < a->elements.length()); + Q_ASSERT(a && i >= 0 && i < a->elements.size()); return QJsonValueRef(this, i); } @@ -486,13 +486,13 @@ bool QJsonArray::operator==(const QJsonArray &other) const return true; if (!a) - return !other.a->elements.length(); + return !other.a->elements.size(); if (!other.a) - return !a->elements.length(); - if (a->elements.length() != other.a->elements.length()) + return !a->elements.size(); + if (a->elements.size() != other.a->elements.size()) return false; - for (qsizetype i = 0; i < a->elements.length(); ++i) { + for (qsizetype i = 0; i < a->elements.size(); ++i) { if (a->valueAt(i) != other.a->valueAt(i)) return false; } diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 814033610f..a77aab3895 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -280,7 +280,7 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const */ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) { - QJsonPrivate::Parser parser(json.constData(), json.length()); + QJsonPrivate::Parser parser(json.constData(), json.size()); QJsonDocument result; const QCborValue val = parser.parse(error); if (val.isArray() || val.isMap()) { diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index 0a5bafd1cb..e87f46a550 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -236,8 +236,8 @@ QStringList QJsonObject::keys() const { QStringList keys; if (o) { - keys.reserve(o->elements.length() / 2); - for (qsizetype i = 0, end = o->elements.length(); i < end; i += 2) + keys.reserve(o->elements.size() / 2); + for (qsizetype i = 0, end = o->elements.size(); i < end; i += 2) keys.append(o->stringAt(i)); } return keys; @@ -248,7 +248,7 @@ QStringList QJsonObject::keys() const */ qsizetype QJsonObject::size() const { - return o ? o->elements.length() / 2 : 0; + return o ? o->elements.size() / 2 : 0; } /*! @@ -400,7 +400,7 @@ QJsonValueRef QJsonObject::atImpl(T key) bool keyExists = false; auto index = indexOf(o, key, &keyExists); if (!keyExists) { - detach(o->elements.length() / 2 + 1); + detach(o->elements.size() / 2 + 1); o->insertAt(index, key); o->insertAt(index + 1, QCborValue::fromJsonValue(QJsonValue())); } @@ -466,7 +466,7 @@ template <typename T> QJsonObject::iterator QJsonObject::insertAt(qsizetype pos, T key, const QJsonValue &value, bool keyExists) { if (o) - detach(o->elements.length() / 2 + (keyExists ? 0 : 1)); + detach(o->elements.size() / 2 + (keyExists ? 0 : 1)); else o = new QCborContainerPrivate; @@ -627,13 +627,13 @@ bool QJsonObject::operator==(const QJsonObject &other) const return true; if (!o) - return !other.o->elements.length(); + return !other.o->elements.size(); if (!other.o) - return !o->elements.length(); - if (o->elements.length() != other.o->elements.length()) + return !o->elements.size(); + if (o->elements.size() != other.o->elements.size()) return false; - for (qsizetype i = 0, end = o->elements.length(); i < end; ++i) { + for (qsizetype i = 0, end = o->elements.size(); i < end; ++i) { if (o->valueAt(i) != other.o->valueAt(i)) return false; } @@ -1360,7 +1360,7 @@ bool QJsonObject::detach(qsizetype reserve) { if (!o) return true; - o = QCborContainerPrivate::detach(o.data(), reserve ? reserve * 2 : o->elements.length()); + o = QCborContainerPrivate::detach(o.data(), reserve ? reserve * 2 : o->elements.size()); return o; } @@ -1370,7 +1370,7 @@ bool QJsonObject::detach(qsizetype reserve) */ QString QJsonObject::keyAt(qsizetype i) const { - Q_ASSERT(o && i >= 0 && i * 2 < o->elements.length()); + Q_ASSERT(o && i >= 0 && i * 2 < o->elements.size()); return o->stringAt(i * 2); } @@ -1379,7 +1379,7 @@ QString QJsonObject::keyAt(qsizetype i) const */ QJsonValue QJsonObject::valueAt(qsizetype i) const { - if (!o || i < 0 || 2 * i + 1 >= o->elements.length()) + if (!o || i < 0 || 2 * i + 1 >= o->elements.size()) return QJsonValue(QJsonValue::Undefined); return QJsonPrivate::Value::fromTrustedCbor(o->valueAt(2 * i + 1)); } @@ -1389,7 +1389,7 @@ QJsonValue QJsonObject::valueAt(qsizetype i) const */ void QJsonObject::setValueAt(qsizetype i, const QJsonValue &val) { - Q_ASSERT(o && i >= 0 && 2 * i + 1 < o->elements.length()); + Q_ASSERT(o && i >= 0 && 2 * i + 1 < o->elements.size()); detach(); if (val.isUndefined()) { o->removeAt(2 * i + 1); diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp index 294a65fa86..acc2bc383f 100644 --- a/src/corelib/serialization/qjsonparser.cpp +++ b/src/corelib/serialization/qjsonparser.cpp @@ -552,7 +552,7 @@ bool Parser::parseArray() } } - DEBUG << "size =" << (container ? container->elements.length() : 0); + DEBUG << "size =" << (container ? container->elements.size() : 0); END; --nestingLevel; diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp index f4ec110684..b0e6ef1d0c 100644 --- a/src/corelib/serialization/qjsonwriter.cpp +++ b/src/corelib/serialization/qjsonwriter.cpp @@ -25,10 +25,10 @@ static inline uchar hexdig(uint u) static QByteArray escapedString(const QString &s) { // give it a minimum size to ensure the resize() below always adds enough space - QByteArray ba(qMax(s.length(), 16), Qt::Uninitialized); + QByteArray ba(qMax(s.size(), 16), Qt::Uninitialized); uchar *cursor = reinterpret_cast<uchar *>(const_cast<char *>(ba.constData())); - const uchar *ba_end = cursor + ba.length(); + const uchar *ba_end = cursor + ba.size(); const char16_t *src = reinterpret_cast<const char16_t *>(s.constBegin()); const char16_t *const end = reinterpret_cast<const char16_t *>(s.constEnd()); @@ -38,7 +38,7 @@ static QByteArray escapedString(const QString &s) int pos = cursor - (const uchar *)ba.constData(); ba.resize(ba.size()*2); cursor = (uchar *)ba.data() + pos; - ba_end = (const uchar *)ba.constData() + ba.length(); + ba_end = (const uchar *)ba.constData() + ba.size(); } char16_t u = *src++; diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index ca2f0684d4..2a2536aeee 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -2497,7 +2497,7 @@ QTextStream &QTextStream::operator<<(const QByteArray &array) { Q_D(QTextStream); CHECK_VALID_STREAM(*this); - d->putString(QString::fromUtf8(array.constData(), array.length())); + d->putString(QString::fromUtf8(array.constData(), array.size())); return *this; } diff --git a/src/corelib/serialization/qtextstream_p.h b/src/corelib/serialization/qtextstream_p.h index c5967845f9..909b75d0de 100644 --- a/src/corelib/serialization/qtextstream_p.h +++ b/src/corelib/serialization/qtextstream_p.h @@ -139,14 +139,14 @@ public: NumberParsingStatus getNumber(qulonglong *l); bool getReal(double *f); - inline void write(QStringView data) { write(data.begin(), data.length()); } + inline void write(QStringView data) { write(data.begin(), data.size()); } inline void write(QChar ch); void write(const QChar *data, qsizetype len); void write(QLatin1StringView data); void writePadding(qsizetype len); inline void putString(QStringView string, bool number = false) { - putString(string.constData(), string.length(), number); + putString(string.constData(), string.size(), number); } void putString(const QChar *data, qsizetype len, bool number = false); void putString(QLatin1StringView data, bool number = false); diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index a6a2bc41af..b76243c176 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -3035,7 +3035,7 @@ void QXmlStreamWriterPrivate::indent(int level) { write("\n"); for (int i = level; i > 0; --i) - write(autoFormattingIndent.constData(), autoFormattingIndent.length()); + write(autoFormattingIndent.constData(), autoFormattingIndent.size()); } diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index 8e523f9c67..1fd69a2c1f 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -42,7 +42,7 @@ public: { } XmlStringRef(const QString *string) - : XmlStringRef(string, 0, string->length()) + : XmlStringRef(string, 0, string->size()) { } diff --git a/src/corelib/text/qbytedata_p.h b/src/corelib/text/qbytedata_p.h index 46eee13ccd..699b418465 100644 --- a/src/corelib/text/qbytedata_p.h +++ b/src/corelib/text/qbytedata_p.h @@ -241,7 +241,7 @@ public: // the number of QByteArrays inline int bufferCount() const { - return buffers.length(); + return buffers.size(); } inline bool isEmpty() const @@ -267,12 +267,12 @@ public: inline bool canReadLine() const { int i = 0; - if (i < buffers.length()) { + if (i < buffers.size()) { if (buffers.at(i).indexOf('\n', firstPos) != -1) return true; ++i; - for (; i < buffers.length(); i++) + for (; i < buffers.size(); i++) if (buffers.at(i).contains('\n')) return true; } diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index d5441817d9..a66325f6a5 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -1815,7 +1815,7 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion QString &s = *str; const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data()); - const unsigned short *uc = utf16 + s.length(); + const unsigned short *uc = utf16 + s.size(); while (uc != utf16 + from) { char32_t ucs4 = *(--uc); if (QChar(ucs4).isLowSurrogate() && uc != utf16) { @@ -1910,7 +1910,7 @@ static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype { QString &s = *str; - if (from < 0 || s.length() - from < 2) + if (from < 0 || s.size() - from < 2) return; char32_t stcode = 0; // starter code point @@ -1919,10 +1919,10 @@ static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype int lastCombining = 255; // to prevent combining > lastCombining qsizetype pos = from; - while (pos < s.length()) { + while (pos < s.size()) { qsizetype i = pos; char32_t uc = s.at(pos).unicode(); - if (QChar(uc).isHighSurrogate() && pos < s.length()-1) { + if (QChar(uc).isHighSurrogate() && pos < s.size()-1) { ushort low = s.at(pos+1).unicode(); if (QChar(low).isLowSurrogate()) { uc = QChar::surrogateToUcs4(uc, low); @@ -1969,7 +1969,7 @@ static void composeHelper(QString *str, QChar::UnicodeVersion version, qsizetype static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, qsizetype from) { QString &s = *str; - const qsizetype l = s.length()-1; + const qsizetype l = s.size()-1; char32_t u1, u2; char16_t c1, c2; @@ -2058,7 +2058,7 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 }; const ushort *string = reinterpret_cast<const ushort *>(str->constData()); - qsizetype length = str->length(); + qsizetype length = str->size(); // this avoids one out of bounds check in the loop while (length > from && QChar::isHighSurrogate(string[length - 1])) @@ -2101,8 +2101,8 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo *lastStable = pos; } - if (length != str->length()) // low surrogate parts at the end of text - *lastStable = str->length() - 1; + if (length != str->size()) // low surrogate parts at the end of text + *lastStable = str->size() - 1; return true; } diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index de262d201e..fe23dc6450 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -559,7 +559,7 @@ static bool isScript(QStringView tag) static const QString allScripts = QString::fromLatin1(reinterpret_cast<const char *>(script_code_list), sizeof(script_code_list) - 1); - return tag.length() == 4 && allScripts.indexOf(tag) % 4 == 0; + return tag.size() == 4 && allScripts.indexOf(tag) % 4 == 0; } bool qt_splitLocaleName(QStringView name, QStringView *lang, QStringView *script, QStringView *land) @@ -3698,11 +3698,11 @@ QString QLocaleData::decimalForm(QString &&digits, int decpt, int precision, digits.append(zero); break; case PMChopTrailingZeros: - Q_ASSERT(digits.length() / digitWidth <= qMax(decpt, 1) || !digits.endsWith(zero)); + Q_ASSERT(digits.size() / digitWidth <= qMax(decpt, 1) || !digits.endsWith(zero)); break; } - if (mustMarkDecimal || decpt < digits.length() / digitWidth) + if (mustMarkDecimal || decpt < digits.size() / digitWidth) digits.insert(decpt * digitWidth, decimalPoint()); if (groupDigits) { @@ -3740,11 +3740,11 @@ QString QLocaleData::exponentForm(QString &&digits, int decpt, int precision, digits.append(zero); break; case PMChopTrailingZeros: - Q_ASSERT(digits.length() / digitWidth <= 1 || !digits.endsWith(zero)); + Q_ASSERT(digits.size() / digitWidth <= 1 || !digits.endsWith(zero)); break; } - if (mustMarkDecimal || digits.length() > digitWidth) + if (mustMarkDecimal || digits.size() > digitWidth) digits.insert(digitWidth, decimalPoint()); digits.append(exponentSeparator()); @@ -3793,7 +3793,7 @@ QString QLocaleData::applyIntegerFormatting(QString &&numStr, bool negative, int { const QString zero = base == 10 ? zeroDigit() : QStringLiteral("0"); const auto digitWidth = zero.size(); - const auto digitCount = numStr.length() / digitWidth; + const auto digitCount = numStr.size() / digitWidth; const auto basePrefix = [&] () -> QStringView { if (flags & ShowBase) { @@ -3986,7 +3986,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray int decDigits, QLocale::NumberOptions number_options) const { buff->clear(); - buff->reserve(str.length()); + buff->reserve(str.size()); enum { Whole, Fractional, Exponent } state = Whole; const bool scientific = numMode == DoubleScientificMode; @@ -4082,7 +4082,7 @@ double QLocaleData::stringToDouble(QStringView str, bool *ok, } int processed = 0; bool nonNullOk = false; - double d = qt_asciiToDouble(buff.constData(), buff.length() - 1, nonNullOk, processed); + double d = qt_asciiToDouble(buff.constData(), buff.size() - 1, nonNullOk, processed); if (ok != nullptr) *ok = nonNullOk; return d; diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index 7a37af541b..c211e57812 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -667,7 +667,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u bool negative = false; int length = 0; int decpt = 0; - qt_doubleToAscii(d, form, precision, buffer.data(), buffer.length(), negative, length, decpt); + qt_doubleToAscii(d, form, precision, buffer.data(), buffer.size(), negative, length, decpt); QLatin1StringView view(buffer.data(), length); const bool succinct = form == QLocaleData::DFSignificantDigits; qsizetype total = (negative ? 1 : 0) + length; diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index a9b7f99975..a523a64788 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -894,7 +894,7 @@ void QRegularExpressionPrivate::compilePattern() PCRE2_SIZE patternErrorOffset; compiledPattern = pcre2_compile_16(reinterpret_cast<PCRE2_SPTR16>(pattern.constData()), - pattern.length(), + pattern.size(), options, &errorCode, &patternErrorOffset, @@ -1547,10 +1547,10 @@ QString QRegularExpression::errorString() const QString errorString; int errorStringLength; do { - errorString.resize(errorString.length() + 64); + errorString.resize(errorString.size() + 64); errorStringLength = pcre2_get_error_message_16(d->errorCode, reinterpret_cast<ushort *>(errorString.data()), - errorString.length()); + errorString.size()); } while (errorStringLength < 0); errorString.resize(errorStringLength); diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 90c51b365b..45b16fb94d 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2654,9 +2654,9 @@ void QString::resize(qsizetype size) void QString::resize(qsizetype newSize, QChar fillChar) { - const qsizetype oldSize = length(); + const qsizetype oldSize = size(); resize(newSize); - const qsizetype difference = length() - oldSize; + const qsizetype difference = size() - oldSize; if (difference > 0) std::fill_n(d.data() + oldSize, difference, fillChar.unicode()); } @@ -3388,7 +3388,7 @@ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs) */ QString &QString::replace(qsizetype pos, qsizetype len, const QString &after) { - return replace(pos, len, after.constData(), after.length()); + return replace(pos, len, after.constData(), after.size()); } /*! @@ -4110,7 +4110,7 @@ QString &QString::replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity */ qsizetype QString::indexOf(const QString &str, qsizetype from, Qt::CaseSensitivity cs) const { - return QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs); + return QtPrivate::findString(QStringView(unicode(), size()), from, QStringView(str.unicode(), str.size()), cs); } /*! @@ -4164,7 +4164,7 @@ qsizetype QString::indexOf(QLatin1StringView str, qsizetype from, Qt::CaseSensit */ qsizetype QString::indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const { - return qFindChar(QStringView(unicode(), length()), ch, from, cs); + return qFindChar(QStringView(unicode(), size()), ch, from, cs); } /*! @@ -4364,7 +4364,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) // 1. build the backreferences list, holding where the backreferences // are in the replacement string QList<QStringCapture> backReferences; - const qsizetype al = after.length(); + const qsizetype al = after.size(); const QChar *ac = after.unicode(); for (qsizetype i = 0; i < al - 1; i++) { @@ -4428,7 +4428,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) } // add the last part of the after string - len = afterView.length() - lastEnd; + len = afterView.size() - lastEnd; if (len > 0) { chunks << afterView.mid(lastEnd, len); newLength += len; @@ -4438,9 +4438,9 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) } // 3. trailing string after the last match - if (copyView.length() > lastEnd) { + if (copyView.size() > lastEnd) { chunks << copyView.mid(lastEnd); - newLength += copyView.length() - lastEnd; + newLength += copyView.size() - lastEnd; } // 4. assemble the chunks together @@ -4448,7 +4448,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) qsizetype i = 0; QChar *uc = data(); for (const QStringView &chunk : qAsConst(chunks)) { - qsizetype len = chunk.length(); + qsizetype len = chunk.size(); memcpy(uc + i, chunk.constData(), len * sizeof(QChar)); i += len; } @@ -4811,7 +4811,7 @@ static QString extractSections(const QList<qt_section_chunk> §ions, qsizetyp qsizetype skip = 0; for (qsizetype k = 0; k < sectionsSize; ++k) { const qt_section_chunk §ion = sections.at(k); - if (section.length == section.string.length()) + if (section.length == section.string.size()) skip++; } if (start < 0) @@ -4827,7 +4827,7 @@ static QString extractSections(const QList<qt_section_chunk> §ions, qsizetyp qsizetype first_i = start, last_i = end; for (qsizetype i = 0; x <= end && i < sectionsSize; ++i) { const qt_section_chunk §ion = sections.at(i); - const bool empty = (section.length == section.string.length()); + const bool empty = (section.length == section.string.size()); if (x >= start) { if (x == start) first_i = i; @@ -4886,7 +4886,7 @@ QString QString::section(const QRegularExpression &re, qsizetype start, qsizetyp sep.setPatternOptions(sep.patternOptions() | QRegularExpression::CaseInsensitiveOption); QList<qt_section_chunk> sections; - qsizetype n = length(), m = 0, last_m = 0, last_len = 0; + qsizetype n = size(), m = 0, last_m = 0, last_len = 0; QRegularExpressionMatchIterator iterator = sep.globalMatch(*this); while (iterator.hasNext()) { QRegularExpressionMatch match = iterator.next(); @@ -5244,7 +5244,7 @@ static QByteArray qt_convert_to_latin1(QStringView string) if (Q_UNLIKELY(string.isNull())) return QByteArray(); - QByteArray ba(string.length(), Qt::Uninitialized); + QByteArray ba(string.size(), Qt::Uninitialized); // since we own the only copy, we're going to const_cast the constData; // that avoids an unnecessary call to detach() and expansion code that will never get used @@ -5413,7 +5413,7 @@ QList<uint> QString::toUcs4() const static QList<uint> qt_convert_to_ucs4(QStringView string) { - QList<uint> v(string.length()); + QList<uint> v(string.size()); uint *a = const_cast<uint*>(v.constData()); QStringIterator it(string); while (it.hasNext()) @@ -6369,7 +6369,7 @@ int QLatin1StringView::compare_helper(const QChar *data1, qsizetype length1, QLa */ int QString::localeAwareCompare(const QString &other) const { - return localeAwareCompare_helper(constData(), length(), other.constData(), other.length()); + return localeAwareCompare_helper(constData(), size(), other.constData(), other.size()); } /*! @@ -6485,7 +6485,7 @@ const ushort *QString::utf16() const QString QString::leftJustified(qsizetype width, QChar fill, bool truncate) const { QString result; - qsizetype len = length(); + qsizetype len = size(); qsizetype padlen = width - len; if (padlen > 0) { result.resize(len+padlen); @@ -6524,7 +6524,7 @@ QString QString::leftJustified(qsizetype width, QChar fill, bool truncate) const QString QString::rightJustified(qsizetype width, QChar fill, bool truncate) const { QString result; - qsizetype len = length(); + qsizetype len = size(); qsizetype padlen = width - len; if (padlen > 0) { result.resize(len+padlen); @@ -7026,27 +7026,27 @@ QString QString::vasprintf(const char *cformat, va_list ap) switch (length_mod) { case lm_hh: { signed char *n = va_arg(ap, signed char*); - *n = result.length(); + *n = result.size(); break; } case lm_h: { short int *n = va_arg(ap, short int*); - *n = result.length(); + *n = result.size(); break; } case lm_l: { long int *n = va_arg(ap, long int*); - *n = result.length(); + *n = result.size(); break; } case lm_ll: { qint64 *n = va_arg(ap, qint64*); - *n = result.length(); + *n = result.size(); break; } default: { int *n = va_arg(ap, int*); - *n = result.length(); + *n = result.size(); break; } } @@ -7862,7 +7862,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: // check if it's fully ASCII first, because then we have no work auto start = reinterpret_cast<const char16_t *>(data->constData()); const char16_t *p = start + from; - if (isAscii_helper(p, p + data->length() - from)) + if (isAscii_helper(p, p + data->size() - from)) return; if (p > start + from) from = p - start - 1; // need one before the non-ASCII to perform NFC @@ -7882,7 +7882,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: char16_t ucs4Low = QChar::lowSurrogate(n.ucs4); char16_t oldHigh = QChar::highSurrogate(n.old_mapping); char16_t oldLow = QChar::lowSurrogate(n.old_mapping); - while (pos < s.length() - 1) { + while (pos < s.size() - 1) { if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) { if (!d) d = data->data(); @@ -7892,7 +7892,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: ++pos; } } else { - while (pos < s.length()) { + while (pos < s.size()) { if (s.at(pos).unicode() == n.ucs4) { if (!d) d = data->data(); @@ -8049,9 +8049,9 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp // Negative field-width for right-padding, positive for left-padding: const qsizetype abs_field_width = qAbs(field_width); const qsizetype result_len = - s.length() - d.escape_len - + (d.occurrences - d.locale_occurrences) * qMax(abs_field_width, arg.length()) - + d.locale_occurrences * qMax(abs_field_width, larg.length()); + s.size() - d.escape_len + + (d.occurrences - d.locale_occurrences) * qMax(abs_field_width, arg.size()) + + d.locale_occurrences * qMax(abs_field_width, larg.size()); QString result(result_len, Qt::Uninitialized); QChar *rc = const_cast<QChar *>(result.unicode()); @@ -8094,7 +8094,7 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp rc += escape_start - text_start; const QStringView use = localize ? larg : arg; - const qsizetype pad_chars = abs_field_width - use.length(); + const qsizetype pad_chars = abs_field_width - use.size(); // (If negative, relevant loops are no-ops: no need to check.) if (field_width > 0) { // left padded @@ -8102,8 +8102,8 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp *rc++ = fillChar; } - memcpy(rc, use.data(), use.length() * sizeof(QChar)); - rc += use.length(); + memcpy(rc, use.data(), use.size() * sizeof(QChar)); + rc += use.size(); if (field_width < 0) { // right padded for (qsizetype i = 0; i < pad_chars; ++i) @@ -8337,7 +8337,7 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons if (d.occurrences > d.locale_occurrences) { arg = QLocaleData::c()->longLongToString(a, -1, base, fieldWidth, flags); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= arg.length()); + || fieldWidth <= arg.size()); } QString localeArg; @@ -8347,7 +8347,7 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons flags |= QLocaleData::GroupDigits; localeArg = locale.d->m_data->longLongToString(a, -1, base, fieldWidth, flags); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= localeArg.length()); + || fieldWidth <= localeArg.size()); } return replaceArgEscapes(*this, d, fieldWidth, arg, localeArg, fillChar); @@ -8385,7 +8385,7 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con if (d.occurrences > d.locale_occurrences) { arg = QLocaleData::c()->unsLongLongToString(a, -1, base, fieldWidth, flags); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= arg.length()); + || fieldWidth <= arg.size()); } QString localeArg; @@ -8395,7 +8395,7 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con flags |= QLocaleData::GroupDigits; localeArg = locale.d->m_data->unsLongLongToString(a, -1, base, fieldWidth, flags); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= localeArg.length()); + || fieldWidth <= localeArg.size()); } return replaceArgEscapes(*this, d, fieldWidth, arg, localeArg, fillChar); @@ -8507,7 +8507,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar arg = QLocaleData::c()->doubleToString(a, precision, form, fieldWidth, flags | QLocaleData::ZeroPadExponent); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= arg.length()); + || fieldWidth <= arg.size()); } QString localeArg; @@ -8523,7 +8523,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar flags |= QLocaleData::AddTrailingZeroes; localeArg = locale.d->m_data->doubleToString(a, precision, form, fieldWidth, flags); Q_ASSERT(fillChar != u'0' || !qIsFinite(a) - || fieldWidth <= localeArg.length()); + || fieldWidth <= localeArg.size()); } return replaceArgEscapes(*this, d, fieldWidth, arg, localeArg, fillChar); @@ -10276,10 +10276,10 @@ QDataStream &operator<<(QDataStream &out, const QString &str) if (!str.isNull() || out.version() < 3) { if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { out.writeBytes(reinterpret_cast<const char *>(str.unicode()), - static_cast<uint>(sizeof(QChar) * str.length())); + static_cast<uint>(sizeof(QChar) * str.size())); } else { - QVarLengthArray<char16_t> buffer(str.length()); - qbswap<sizeof(char16_t)>(str.constData(), str.length(), buffer.data()); + QVarLengthArray<char16_t> buffer(str.size()); + qbswap<sizeof(char16_t)>(str.constData(), str.size(), buffer.data()); out.writeBytes(reinterpret_cast<const char *>(buffer.data()), static_cast<uint>(sizeof(char16_t) * buffer.size())); } @@ -10902,7 +10902,7 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re) } qsizetype count = 0; qsizetype index = -1; - qsizetype len = haystack.length(); + qsizetype len = haystack.size(); while (index <= len - 1) { QRegularExpressionMatch match = re.match(haystack, index + 1); if (!match.hasMatch()) @@ -10929,7 +10929,7 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re) QString QString::toHtmlEscaped() const { QString rich; - const qsizetype len = length(); + const qsizetype len = size(); rich.reserve(qsizetype(len * 1.1)); for (QChar ch : *this) { if (ch == u'<') diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 3f15001ff8..acb34ccdd1 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -678,20 +678,20 @@ public: QString &insert(qsizetype i, QChar c); QString &insert(qsizetype i, const QChar *uc, qsizetype len); - inline QString &insert(qsizetype i, const QString &s) { return insert(i, s.constData(), s.length()); } - inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.length()); } + inline QString &insert(qsizetype i, const QString &s) { return insert(i, s.constData(), s.size()); } + inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.size()); } QString &insert(qsizetype i, QLatin1StringView s); QString &append(QChar c); QString &append(const QChar *uc, qsizetype len); QString &append(const QString &s); - inline QString &append(QStringView v) { return append(v.data(), v.length()); } + inline QString &append(QStringView v) { return append(v.data(), v.size()); } QString &append(QLatin1StringView s); inline QString &prepend(QChar c) { return insert(0, c); } inline QString &prepend(const QChar *uc, qsizetype len) { return insert(0, uc, len); } inline QString &prepend(const QString &s) { return insert(0, s); } - inline QString &prepend(QStringView v) { return prepend(v.data(), v.length()); } + inline QString &prepend(QStringView v) { return prepend(v.data(), v.size()); } inline QString &prepend(QLatin1StringView s) { return insert(0, s); } inline QString &operator+=(QChar c) { return append(c); } @@ -1192,7 +1192,7 @@ QString QLatin1StringView::toString() const { return *this; } // QString QStringView::toString() const -{ return Q_ASSERT(size() == length()), QString(data(), length()); } +{ return Q_ASSERT(size() == size()), QString(data(), size()); } qint64 QStringView::toLongLong(bool *ok, int base) const { return QString::toIntegral_helper<qint64>(*this, ok, base); } @@ -1482,7 +1482,7 @@ inline QString QString::fromStdString(const std::string &s) inline std::wstring QString::toStdWString() const { std::wstring str; - str.resize(length()); + str.resize(size()); str.resize(toWCharArray(str.data())); return str; } @@ -1494,16 +1494,16 @@ inline QString QString::fromStdU16String(const std::u16string &s) { return fromUtf16(s.data(), qsizetype(s.size())); } inline std::u16string QString::toStdU16String() const -{ return std::u16string(reinterpret_cast<const char16_t*>(data()), length()); } +{ return std::u16string(reinterpret_cast<const char16_t*>(data()), size()); } inline QString QString::fromStdU32String(const std::u32string &s) { return fromUcs4(s.data(), qsizetype(s.size())); } inline std::u32string QString::toStdU32String() const { - std::u32string u32str(length(), char32_t(0)); + std::u32string u32str(size(), char32_t(0)); qsizetype len = toUcs4_helper(reinterpret_cast<const ushort *>(constData()), - length(), reinterpret_cast<uint*>(&u32str[0])); + size(), reinterpret_cast<uint*>(&u32str[0])); u32str.resize(len); return u32str; } @@ -1520,9 +1520,9 @@ inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcep { return -s.compare(*this, cs); } inline int QString::localeAwareCompare(QStringView s) const -{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); } +{ return localeAwareCompare_helper(constData(), size(), s.constData(), s.size()); } inline int QString::localeAwareCompare(QStringView s1, QStringView s2) -{ return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); } +{ return localeAwareCompare_helper(s1.constData(), s1.size(), s2.constData(), s2.size()); } inline int QStringView::localeAwareCompare(QStringView other) const { return QString::localeAwareCompare(*this, other); } diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 021083b1ec..04e70949dd 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -505,7 +505,7 @@ char *QUtf8::convertFromUnicode(char *out, QStringView in, QStringConverter::Sta { Q_ASSERT(state); const QChar *uc = in.data(); - qsizetype len = in.length(); + qsizetype len = in.size(); if (!len) return out; @@ -878,7 +878,7 @@ QByteArray QUtf16::convertFromUnicode(QStringView in, QStringConverter::State *s QByteArray d(length, Qt::Uninitialized); char *end = convertFromUnicode(d.data(), in, state, endian); - Q_ASSERT(end - d.constData() == d.length()); + Q_ASSERT(end - d.constData() == d.size()); Q_UNUSED(end); return d; } @@ -901,13 +901,13 @@ char *QUtf16::convertFromUnicode(char *out, QStringView in, QStringConverter::St out += 2; } if (endian == BigEndianness) - qToBigEndian<char16_t>(in.data(), in.length(), out); + qToBigEndian<char16_t>(in.data(), in.size(), out); else - qToLittleEndian<char16_t>(in.data(), in.length(), out); + qToLittleEndian<char16_t>(in.data(), in.size(), out); state->remainingChars = 0; state->internalState |= HeaderDone; - return out + 2*in.length(); + return out + 2*in.size(); } QString QUtf16::convertToUnicode(QByteArrayView in, QStringConverter::State *state, DataEndianness endian) @@ -1037,7 +1037,7 @@ char *QUtf32::convertFromUnicode(char *out, QStringView in, QStringConverter::St } const QChar *uc = in.data(); - const QChar *end = in.data() + in.length(); + const QChar *end = in.data() + in.size(); QChar ch; char32_t ucs4; if (state->remainingChars == 1) { @@ -1475,7 +1475,7 @@ static char *toLatin1(char *out, QStringView in, QStringConverter::State *state) const char replacement = (state && state->flags & QStringConverter::Flag::ConvertInvalidToNull) ? 0 : '?'; qsizetype invalid = 0; - for (qsizetype i = 0; i < in.length(); ++i) { + for (qsizetype i = 0; i < in.size(); ++i) { if (in[i] > QChar(0xff)) { *out = replacement; ++invalid; @@ -1492,15 +1492,15 @@ static char *toLatin1(char *out, QStringView in, QStringConverter::State *state) static QChar *fromLocal8Bit(QChar *out, QByteArrayView in, QStringConverter::State *state) { QString s = QLocal8Bit::convertToUnicode(in, state); - memcpy(out, s.constData(), s.length()*sizeof(QChar)); - return out + s.length(); + memcpy(out, s.constData(), s.size()*sizeof(QChar)); + return out + s.size(); } static char *toLocal8Bit(char *out, QStringView in, QStringConverter::State *state) { QByteArray s = QLocal8Bit::convertFromUnicode(in, state); - memcpy(out, s.constData(), s.length()); - return out + s.length(); + memcpy(out, s.constData(), s.size()); + return out + s.size(); } @@ -1751,7 +1751,7 @@ struct QStringConverterICU : QStringConverter auto source = reinterpret_cast<const UChar *>(in.data()); auto sourceLimit = reinterpret_cast<const UChar *>(in.data() + in.size()); - qsizetype length = UCNV_GET_MAX_BYTES_FOR_STRING(in.length(), ucnv_getMaxCharSize(icu_conv)); + qsizetype length = UCNV_GET_MAX_BYTES_FOR_STRING(in.size(), ucnv_getMaxCharSize(icu_conv)); char *target = out; char *targetLimit = out + length; diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp index 8eb730ee02..2c0dc77a5a 100644 --- a/src/corelib/text/qstringlist.cpp +++ b/src/corelib/text/qstringlist.cpp @@ -387,7 +387,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, QStringView befo QStringView after, Qt::CaseSensitivity cs) { for (qsizetype i = 0; i < that->size(); ++i) - (*that)[i].replace(before.data(), before.length(), after.data(), after.length(), cs); + (*that)[i].replace(before.data(), before.size(), after.data(), after.size(), cs); } #if QT_CONFIG(regularexpression) @@ -492,7 +492,7 @@ QString QtPrivate::QStringList_join(const QStringList &list, QLatin1StringView s */ QString QtPrivate::QStringList_join(const QStringList *that, QStringView sep) { - return QStringList_join(that, sep.data(), sep.length()); + return QStringList_join(that, sep.data(), sep.size()); } /*! diff --git a/src/corelib/text/qstringlist.h b/src/corelib/text/qstringlist.h index 079f156479..31e4cf6dc9 100644 --- a/src/corelib/text/qstringlist.h +++ b/src/corelib/text/qstringlist.h @@ -87,7 +87,7 @@ public: } inline QString join(const QString &sep) const - { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); } + { return QtPrivate::QStringList_join(self(), sep.constData(), sep.size()); } inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return QtPrivate::QStringList_filter(self(), str, cs); } inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive) diff --git a/src/corelib/text/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp index 937f88b252..8f20967a1d 100644 --- a/src/corelib/text/qtextboundaryfinder.cpp +++ b/src/corelib/text/qtextboundaryfinder.cpp @@ -20,7 +20,7 @@ static void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharA case QTextBoundaryFinder::Line: options |= QUnicodeTools::LineBreaks; break; default: break; } - QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.count(), attributes, options); + QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.size(), attributes, options); } /*! diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index b62ceaf91d..eedfd7ceeb 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -726,7 +726,7 @@ void QFutureInterfaceBasePrivate::sendCallOut(const QFutureCallOutEvent &callOut if (outputConnections.isEmpty()) return; - for (int i = 0; i < outputConnections.count(); ++i) + for (int i = 0; i < outputConnections.size(); ++i) outputConnections.at(i)->postCallOutEvent(callOutEvent); } @@ -736,7 +736,7 @@ void QFutureInterfaceBasePrivate::sendCallOuts(const QFutureCallOutEvent &callOu if (outputConnections.isEmpty()) return; - for (int i = 0; i < outputConnections.count(); ++i) { + for (int i = 0; i < outputConnections.size(); ++i) { QFutureCallOutInterface *interface = outputConnections.at(i); interface->postCallOutEvent(callOutEvent1); interface->postCallOutEvent(callOutEvent2); diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index eb251c7d14..418f19866d 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -347,7 +347,7 @@ inline bool QFutureInterface<T>::reportResults(const QList<T> &_results, int beg if (store.filterMode()) { this->reportResultsReady(resultCountBefore, store.count()); } else { - this->reportResultsReady(insertIndex, insertIndex + _results.count()); + this->reportResultsReady(insertIndex, insertIndex + _results.size()); } return true; } diff --git a/src/corelib/thread/qfuturesynchronizer.h b/src/corelib/thread/qfuturesynchronizer.h index 8b85e20038..2cf2ca1b76 100644 --- a/src/corelib/thread/qfuturesynchronizer.h +++ b/src/corelib/thread/qfuturesynchronizer.h @@ -38,12 +38,12 @@ public: void waitForFinished() { if (m_cancelOnWait) { - for (int i = 0; i < m_futures.count(); ++i) { + for (int i = 0; i < m_futures.size(); ++i) { m_futures[i].cancel(); } } - for (int i = 0; i < m_futures.count(); ++i) { + for (int i = 0; i < m_futures.size(); ++i) { m_futures[i].waitForFinished(); } } diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index f633ed7801..2003193d16 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -164,23 +164,23 @@ public: if (containsValidResultItem(index)) // reject if already present return -1; - return addResults(index, new QList<T>(*results), results->count(), results->count()); + return addResults(index, new QList<T>(*results), results->size(), results->size()); } template<typename T> int addResults(int index, const QList<T> *results, int totalCount) { // reject if results are empty, and nothing is filtered away - if ((m_filterMode == false || results->count() == totalCount) && results->empty()) + if ((m_filterMode == false || results->size() == totalCount) && results->empty()) return -1; if (containsValidResultItem(index)) // reject if already present return -1; - if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) + if (m_filterMode == true && results->size() != totalCount && 0 == results->size()) return addResults(index, nullptr, 0, totalCount); - return addResults(index, new QList<T>(*results), results->count(), totalCount); + return addResults(index, new QList<T>(*results), results->size(), totalCount); } int addCanceledResult(int index) diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index b1078dab18..1c3b79033a 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -200,9 +200,9 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority) int QThreadPoolPrivate::activeThreadCount() const { - return (allThreads.count() - - expiredThreads.count() - - waitingThreads.count() + return (allThreads.size() + - expiredThreads.size() + - waitingThreads.size() + reservedThreads); } diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index 55a603e0e6..c2029fe1b3 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -51,15 +51,15 @@ QThreadStorageData::QThreadStorageData(void (*func)(void *)) no where to store it, and no way to actually call it. */ QThreadData *data = QThreadData::current(); - id = data->tls.count(); + id = data->tls.size(); DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func); return; } - for (id = 0; id < destr->count(); id++) { + for (id = 0; id < destr->size(); id++) { if (destr->at(id) == nullptr) break; } - if (id == destr->count()) { + if (id == destr->size()) { destr->append(func); } else { (*destr)[id] = func; diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 4135e60224..5ec745c772 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -122,7 +122,7 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) QDate date; const auto isShortName = [](QStringView name) { - return (name.length() == 3 && name[0].isUpper() + return (name.size() == 3 && name[0].isUpper() && name[1].isLower() && name[2].isLower()); }; @@ -4947,7 +4947,7 @@ QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format) // Documented as "ddd MMM d HH:mm:ss yyyy" with optional offset-suffix; // and allow time either before or after year. - if (parts.count() < 5 || it != tokens.end()) + if (parts.size() < 5 || it != tokens.end()) return QDateTime(); // Year and time can be in either order. @@ -4976,7 +4976,7 @@ QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format) if (!time.isValid()) return QDateTime(); - if (parts.count() == 5) + if (parts.size() == 5) return QDateTime(date, time, Qt::LocalTime); QStringView tz = parts.at(5); diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index 92c7899ac9..4e4cbdb9d6 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -742,7 +742,7 @@ QTimeZone::OffsetDataList QTimeZone::transitions(const QDateTime &fromDateTime, if (hasTransitions()) { const QTimeZonePrivate::DataList plist = d->transitions(fromDateTime.toMSecsSinceEpoch(), toDateTime.toMSecsSinceEpoch()); - list.reserve(plist.count()); + list.reserve(plist.size()); for (const QTimeZonePrivate::Data &pdata : plist) list.append(QTimeZonePrivate::toOffsetData(pdata)); } diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index b04f0f384f..5bdc4e2cc2 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -664,7 +664,7 @@ QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsI QLocale::Territory territory) { const QList<QByteArray> list = windowsIdToIanaIds(windowsId, territory); - return list.count() > 0 ? list.first() : QByteArray(); + return list.size() > 0 ? list.first() : QByteArray(); } QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windowsId) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index d3886435b5..5e61992d65 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -357,7 +357,7 @@ static QDate calculatePosixDate(const QByteArray &dateRule, int year) if (dateRule.at(0) == 'M') { // nth week in month format "Mmonth.week.dow" QList<QByteArray> dateParts = dateRule.split('.'); - if (dateParts.count() > 2) { + if (dateParts.size() > 2) { int month = dateParts.at(0).mid(1).toInt(&ok); int week = ok ? dateParts.at(1).toInt(&ok) : 0; int dow = ok ? dateParts.at(2).toInt(&ok) : 0; @@ -528,7 +528,7 @@ static auto validatePosixRule(const QByteArray &posixRule) // http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html // See also calculatePosixTransition()'s reference. const auto parts = posixRule.split(','); - const struct { bool isValid, hasDst; } fail{false, false}, good{true, parts.count() > 1}; + const struct { bool isValid, hasDst; } fail{false, false}, good{true, parts.size() > 1}; const QByteArray &zoneinfo = parts.at(0); if (zoneinfo.isEmpty()) return fail; @@ -550,13 +550,13 @@ static auto validatePosixRule(const QByteArray &posixRule) return fail; if (good.hasDst) { - if (parts.count() != 3 || parts.at(1).isEmpty() || parts.at(2).isEmpty()) + if (parts.size() != 3 || parts.at(1).isEmpty() || parts.at(2).isEmpty()) return fail; for (int i = 1; i < 3; ++i) { const auto tran = parts.at(i).split('/'); if (!calculatePosixDate(tran.at(0), 1972).isValid()) return fail; - if (tran.count() > 1) { + if (tran.size() > 1) { const auto time = tran.at(1); if (parsePosixTime(time.begin(), time.end()) == INT_MIN) return fail; @@ -597,7 +597,7 @@ static QList<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray } // If only the name part, or no DST specified, then no transitions - if (parts.count() == 1 || !dstZone.hasValidOffset()) { + if (parts.size() == 1 || !dstZone.hasValidOffset()) { QTimeZonePrivate::Data data; data.atMSecsSinceEpoch = lastTranMSecs; data.offsetFromUtc = stdZone.offset; @@ -607,19 +607,19 @@ static QList<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray result << data; return result; } - if (parts.count() < 3 || parts.at(1).isEmpty() || parts.at(2).isEmpty()) + if (parts.size() < 3 || parts.at(1).isEmpty() || parts.at(2).isEmpty()) return result; // Malformed. // Get the std to dst transition details const int twoOClock = 7200; // Default transition time, when none specified const auto dstParts = parts.at(1).split('/'); const QByteArray dstDateRule = dstParts.at(0); - const int dstTime = dstParts.count() < 2 ? twoOClock : parsePosixTransitionTime(dstParts.at(1)); + const int dstTime = dstParts.size() < 2 ? twoOClock : parsePosixTransitionTime(dstParts.at(1)); // Get the dst to std transition details const auto stdParts = parts.at(2).split('/'); const QByteArray stdDateRule = stdParts.at(0); - const int stdTime = stdParts.count() < 2 ? twoOClock : parsePosixTransitionTime(stdParts.at(1)); + const int stdTime = stdParts.size() < 2 ? twoOClock : parsePosixTransitionTime(stdParts.at(1)); if (dstDateRule.isEmpty() || stdDateRule.isEmpty() || dstTime == INT_MIN || stdTime == INT_MIN) return result; // Malformed. @@ -836,7 +836,7 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::findEntry(const QByteArray &ianaId) } // Now for each transition time calculate and store our rule: - const int tranCount = tranList.count();; + const int tranCount = tranList.size();; ret.m_tranTimes.reserve(tranCount); // The DST offset when in effect: usually stable, usually an hour: int lastDstOff = 3600; diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index e771877265..48ad3a177b 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -500,9 +500,9 @@ QString QCommandLineParser::errorText() const { if (!d->errorText.isEmpty()) return d->errorText; - if (d->unknownOptionNames.count() == 1) + if (d->unknownOptionNames.size() == 1) return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first()); - if (d->unknownOptionNames.count() > 1) + if (d->unknownOptionNames.size() > 1) return tr("Unknown options: %1.").arg(d->unknownOptionNames.join(QStringLiteral(", "))); return QString(); } @@ -691,7 +691,7 @@ bool QCommandLineParserPrivate::parse(const QStringList &args) if (forcePositional) { positionalArgumentList.append(argument); } else if (argument.startsWith(doubleDashString)) { - if (argument.length() > 2) { + if (argument.size() > 2) { QString optionName = argument.mid(2).section(assignChar, 0, 0); if (registerFoundOption(optionName)) { if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())) @@ -1042,7 +1042,7 @@ static QString wrapText(const QString &names, int optionNameMaxWidth, const QStr int lastBreakable = -1; const int max = 79 - (indentation.size() + optionNameMaxWidth + 1); int x = 0; - const int len = description.length(); + const int len = description.size(); for (int i = 0; i < len; ++i) { ++x; @@ -1116,7 +1116,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const const QStringList optionNames = option.names(); QString optionNamesString; for (const QString &optionName : optionNames) { - const int numDashes = optionName.length() == 1 ? 1 : 2; + const int numDashes = optionName.size() == 1 ? 1 : 2; optionNamesString += QLatin1StringView("--", numDashes) + optionName + ", "_L1; } if (!optionNames.isEmpty()) @@ -1125,7 +1125,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const if (!valueName.isEmpty()) optionNamesString += " <"_L1 + valueName + u'>'; optionNameList.append(optionNamesString); - longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length()); + longestOptionNameString = qMax(longestOptionNameString, optionNamesString.size()); } ++longestOptionNameString; const int optionNameMaxWidth = qMin(50, longestOptionNameString); diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 9242a617ba..d8b3367de3 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -447,7 +447,7 @@ struct BezierEase : public QEasingCurveFunction { if (_bezierCurves.constLast() == QPointF(1.0, 1.0)) { _init = true; - _curveCount = _bezierCurves.count() / 3; + _curveCount = _bezierCurves.size() / 3; for (int i=0; i < _curveCount; i++) { _intervals[i] = _bezierCurves.at(i * 3 + 2).x(); @@ -466,17 +466,17 @@ struct BezierEase : public QEasingCurveFunction _curves[0].p3y = _bezierCurves.at(2).y(); } else if (i == (_curveCount - 1)) { - _curves[i].p0x = _bezierCurves.at(_bezierCurves.count() - 4).x(); - _curves[i].p0y = _bezierCurves.at(_bezierCurves.count() - 4).y(); + _curves[i].p0x = _bezierCurves.at(_bezierCurves.size() - 4).x(); + _curves[i].p0y = _bezierCurves.at(_bezierCurves.size() - 4).y(); - _curves[i].p1x = _bezierCurves.at(_bezierCurves.count() - 3).x(); - _curves[i].p1y = _bezierCurves.at(_bezierCurves.count() - 3).y(); + _curves[i].p1x = _bezierCurves.at(_bezierCurves.size() - 3).x(); + _curves[i].p1y = _bezierCurves.at(_bezierCurves.size() - 3).y(); - _curves[i].p2x = _bezierCurves.at(_bezierCurves.count() - 2).x(); - _curves[i].p2y = _bezierCurves.at(_bezierCurves.count() - 2).y(); + _curves[i].p2x = _bezierCurves.at(_bezierCurves.size() - 2).x(); + _curves[i].p2y = _bezierCurves.at(_bezierCurves.size() - 2).y(); - _curves[i].p3x = _bezierCurves.at(_bezierCurves.count() - 1).x(); - _curves[i].p3y = _bezierCurves.at(_bezierCurves.count() - 1).y(); + _curves[i].p3x = _bezierCurves.at(_bezierCurves.size() - 1).x(); + _curves[i].p3y = _bezierCurves.at(_bezierCurves.size() - 1).y(); } else { _curves[i].p0x = _bezierCurves.at(i * 3 - 1).x(); _curves[i].p0y = _bezierCurves.at(i * 3 - 1).y(); @@ -535,7 +535,7 @@ struct BezierEase : public QEasingCurveFunction qreal value(qreal x) override { - Q_ASSERT(_bezierCurves.count() % 3 == 0); + Q_ASSERT(_bezierCurves.size() % 3 == 0); if (_bezierCurves.isEmpty()) { return x; @@ -869,7 +869,7 @@ struct TCBEase : public BezierEase qreal value(qreal x) override { - Q_ASSERT(_bezierCurves.count() % 3 == 0); + Q_ASSERT(_bezierCurves.size() % 3 == 0); if (_bezierCurves.isEmpty()) { qWarning("QEasingCurve: Invalid tcb curve"); @@ -1274,7 +1274,7 @@ void QEasingCurve::addCubicBezierSegment(const QPointF & c1, const QPointF & c2, QList<QPointF> static inline tcbToBezier(const TCBPoints &tcbPoints) { - const int count = tcbPoints.count(); + const int count = tcbPoints.size(); QList<QPointF> bezierPoints; bezierPoints.reserve(3 * (count - 1)); diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 2a945a31e8..3ab4c0db76 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -151,7 +151,7 @@ public: // more Qt typedef iterator Iterator; typedef const_iterator ConstIterator; - inline qsizetype count() const { return q_hash.count(); } + inline qsizetype count() const { return q_hash.size(); } inline iterator insert(const T &value) { return q_hash.insert(value, QHashDummyValue()); } inline iterator insert(T &&value) diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index a2afc01e9d..a53ba41683 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -279,7 +279,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void ** qPrintable(errorMsg)); return; } - if (inputCount + 1 != types.count() || + if (inputCount + 1 != types.size() || types.at(inputCount) == QDBusMetaTypeId::message()) { // invalid signal signature qWarning("QDBusAbstractAdaptor: Cannot relay signal %s::%s", @@ -288,7 +288,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void ** } QVariantList args; - const int numTypes = types.count(); + const int numTypes = types.size(); args.reserve(numTypes - 1); for (int i = 1; i < numTypes; ++i) args << QVariant(QMetaType(types.at(i)), argv[i]); diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 893125baa0..af6604bf0f 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -862,7 +862,7 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode; int i = 1; while (node) { - if (pathComponents.count() == i) { + if (pathComponents.size() == i) { // this node exists // consider it free if there's no object here and the user is not trying to // replace the object sub-tree @@ -972,7 +972,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const int i = 1; while (node) { - if (pathComponents.count() == i) + if (pathComponents.size() == i) return node->obj; if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) return node->obj; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index e9b4bd0b1d..0e1f543a1f 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -327,7 +327,7 @@ static QByteArray buildMatchRule(const QString &service, // add the argument string-matching now if (!argMatch.args.isEmpty()) { const QString keyValue = "arg%1='%2',"_L1; - for (int i = 0; i < argMatch.args.count(); ++i) + for (int i = 0; i < argMatch.args.size(); ++i) if (!argMatch.args.at(i).isNull()) result += keyValue.arg(i).arg(argMatch.args.at(i)); } @@ -349,7 +349,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, return root; } int start = 0; - int length = fullpath.length(); + int length = fullpath.size(); if (fullpath.at(0) == u'/') start = 1; @@ -391,7 +391,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *root, const QString &fullpath, int start) { - int length = fullpath.length(); + int length = fullpath.size(); // any object in the tree can tell us to switch to its own object tree: const QDBusConnectionPrivate::ObjectTreeNode *node = root; @@ -575,7 +575,7 @@ static void huntAndUnregister(const QList<QStringView> &pathComponents, int i, QDBusConnection::UnregisterMode mode, QDBusConnectionPrivate::ObjectTreeNode *node) { - if (pathComponents.count() == i) { + if (pathComponents.size() == i) { // found it node->obj = nullptr; node->flags = 0; @@ -699,14 +699,14 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags, continue; bool ok = true; - for (int j = i; ok && j < metaTypes.count(); ++j) + for (int j = i; ok && j < metaTypes.size(); ++j) if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == nullptr) ok = false; if (!ok) continue; // consistency check: - if (isAsync && metaTypes.count() > i + 1) + if (isAsync && metaTypes.size() > i + 1) continue; if (mm.methodType() == QMetaMethod::Slot) { @@ -753,11 +753,11 @@ QDBusCallDeliveryEvent *QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv Q_ASSERT(object); Q_UNUSED(object); - int n = metaTypes.count() - 1; + int n = metaTypes.size() - 1; if (metaTypes[n] == QDBusMetaTypeId::message()) --n; - if (msg.arguments().count() < n) + if (msg.arguments().size() < n) return nullptr; // too few arguments // check that types match @@ -829,7 +829,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu qvariant_cast<QDBusSlotCache>(object->property(cachePropertyName)); QString cacheKey = msg.member(), signature = msg.signature(); if (!signature.isEmpty()) { - cacheKey.reserve(cacheKey.length() + 1 + signature.length()); + cacheKey.reserve(cacheKey.size() + 1 + signature.size()); cacheKey += u'.'; cacheKey += signature; } @@ -852,7 +852,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu // ### this is where we want to add the connection as an arg too // try with no parameters, but with a QDBusMessage slotData.slotIdx = ::findSlot(mo, memberName, flags, QString(), slotData.metaTypes); - if (slotData.metaTypes.count() != 2 || + if (slotData.metaTypes.size() != 2 || slotData.metaTypes.at(1) != QDBusMetaTypeId::message()) { // not found // save the negative lookup @@ -890,10 +890,10 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q "function called for an object that is in another thread!!"); QVarLengthArray<void *, 10> params; - params.reserve(metaTypes.count()); + params.reserve(metaTypes.size()); QVarLengthArray<QVariant, 10> auxParameters; // we cannot allow reallocation here, since we - auxParameters.reserve(metaTypes.count()); // keep references to the entries + auxParameters.reserve(metaTypes.size()); // keep references to the entries // let's create the parameter list @@ -902,7 +902,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q // add the input parameters int i; - int pCount = qMin(msg.arguments().count(), metaTypes.count() - 1); + int pCount = qMin(msg.arguments().size(), metaTypes.size() - 1); for (i = 1; i <= pCount; ++i) { auto id = metaTypes[i]; if (id == QDBusMetaTypeId::message()) @@ -918,7 +918,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q const QDBusArgument &in = *reinterpret_cast<const QDBusArgument *>(arg.constData()); - QVariant &out = auxParameters[auxParameters.count() - 1]; + QVariant &out = auxParameters[auxParameters.size() - 1]; if (Q_UNLIKELY(!QDBusMetaType::demarshall(in, out.metaType(), out.data()))) qFatal("Internal error: demarshalling function for type '%s' (%d) failed!", @@ -933,19 +933,19 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q } } - if (metaTypes.count() > i && metaTypes[i] == QDBusMetaTypeId::message()) { + if (metaTypes.size() > i && metaTypes[i] == QDBusMetaTypeId::message()) { params.append(const_cast<void*>(static_cast<const void*>(&msg))); ++i; } // output arguments - const int numMetaTypes = metaTypes.count(); + const int numMetaTypes = metaTypes.size(); QVariantList outputArgs; if (metaTypes[0].id() != QMetaType::Void && metaTypes[0].isValid()) { outputArgs.reserve(numMetaTypes - i + 1); QVariant arg{QMetaType(metaTypes[0])}; outputArgs.append( arg ); - params[0] = const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData()); + params[0] = const_cast<void*>(outputArgs.at( outputArgs.size() - 1 ).constData()); } else { outputArgs.reserve(numMetaTypes - i); } @@ -953,7 +953,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q for ( ; i < numMetaTypes; ++i) { QVariant arg{QMetaType(metaTypes[i])}; outputArgs.append( arg ); - params.append(const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData())); + params.append(const_cast<void*>(outputArgs.at( outputArgs.size() - 1 ).constData())); } // make call: @@ -1296,7 +1296,7 @@ int QDBusConnectionPrivate::findSlot(QObject *obj, const QByteArray &normalizedN QString errorMsg; int inputCount = qDBusParametersForMethod(obj->metaObject()->method(midx), params, errorMsg); - if ( inputCount == -1 || inputCount + 1 != params.count() ) + if ( inputCount == -1 || inputCount + 1 != params.size() ) return -1; // failed to parse or invalid arguments or output arguments return midx; @@ -1333,13 +1333,13 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo mname = QString::fromUtf8(normalizedName); } key = mname; - key.reserve(interface.length() + 1 + mname.length()); + key.reserve(interface.size() + 1 + mname.size()); key += u':'; key += interface; if (buildSignature) { hook.signature.clear(); - for (int i = 1; i < hook.params.count(); ++i) + for (int i = 1; i < hook.params.size(); ++i) if (hook.params.at(i) != QDBusMetaTypeId::message()) hook.signature += QLatin1StringView(QDBusMetaType::typeToSignature(hook.params.at(i))); } @@ -1435,7 +1435,7 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes } } - if (pathStartPos != msg.path().length()) { + if (pathStartPos != msg.path().size()) { node.flags &= ~QDBusConnection::ExportAllSignals; node.obj = findChildObject(&node, msg.path(), pathStartPos); if (!node.obj) { @@ -1653,14 +1653,14 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg) // (but not both) QString key = msg.member(); - key.reserve(key.length() + 1 + msg.interface().length()); + key.reserve(key.size() + 1 + msg.interface().size()); key += u':'; key += msg.interface(); QDBusReadLocker locker(HandleSignalAction, this); handleSignal(key, msg); // one try - key.truncate(msg.member().length() + 1); // keep the ':' + key.truncate(msg.member().size() + 1); // keep the ':' handleSignal(key, msg); // second try key = u':'; diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 11813de537..24b791409a 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -187,7 +187,7 @@ propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, co QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node, const QDBusMessage &msg) { - Q_ASSERT(msg.arguments().count() == 2); + Q_ASSERT(msg.arguments().size() == 2); Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(), "QDBusConnection: internal threading error", "function called for an object that is in another thread!!"); @@ -345,7 +345,7 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node, const QDBusMessage &msg) { - Q_ASSERT(msg.arguments().count() == 3); + Q_ASSERT(msg.arguments().size() == 3); Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(), "QDBusConnection: internal threading error", "function called for an object that is in another thread!!"); @@ -445,7 +445,7 @@ static QVariantMap readAllProperties(QObject *object, int flags) QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &node, const QDBusMessage &msg) { - Q_ASSERT(msg.arguments().count() == 1); + Q_ASSERT(msg.arguments().size() == 1); Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(), "QDBusConnection: internal threading error", "function called for an object that is in another thread!!"); diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index 58575a3d94..b3aaff5374 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -152,7 +152,7 @@ inline void QDBusMarshaller::append(const QByteArray &arg) DBusMessageIter subiterator; q_dbus_message_iter_open_container(&iterator, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &subiterator); - q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.length()); + q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.size()); q_dbus_message_iter_close_container(&iterator, &subiterator); } diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 668a039a46..34bbfa6cb2 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -221,7 +221,7 @@ void QDBusMetaObjectGenerator::parseMethods() bool ok = true; // build the input argument list - for (qsizetype i = 0; i < m.inputArgs.count(); ++i) { + for (qsizetype i = 0; i < m.inputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = m.inputArgs.at(i); Type type = findType(arg.type.toLatin1(), m.annotations, "In", i); @@ -240,7 +240,7 @@ void QDBusMetaObjectGenerator::parseMethods() if (!ok) continue; // build the output argument list: - for (qsizetype i = 0; i < m.outputArgs.count(); ++i) { + for (qsizetype i = 0; i < m.outputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = m.outputArgs.at(i); Type type = findType(arg.type.toLatin1(), m.annotations, "Out", i); @@ -266,7 +266,7 @@ void QDBusMetaObjectGenerator::parseMethods() // convert the last commas: if (!mm.parameterNames.isEmpty()) - prototype[prototype.length() - 1] = ')'; + prototype[prototype.size() - 1] = ')'; else prototype.append(')'); @@ -297,7 +297,7 @@ void QDBusMetaObjectGenerator::parseSignals() bool ok = true; // build the output argument list - for (qsizetype i = 0; i < s.outputArgs.count(); ++i) { + for (qsizetype i = 0; i < s.outputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = s.outputArgs.at(i); Type type = findType(arg.type.toLatin1(), s.annotations, "Out", i); @@ -317,7 +317,7 @@ void QDBusMetaObjectGenerator::parseSignals() // convert the last commas: if (!mm.parameterNames.isEmpty()) - prototype[prototype.length() - 1] = ')'; + prototype[prototype.size() - 1] = ')'; else prototype.append(')'); @@ -387,8 +387,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) qsizetype methodParametersDataSize = ((aggregateParameterCount(signals_) + aggregateParameterCount(methods)) * 2) // types and parameter names - - signals_.count() // return "parameters" don't have names - - methods.count(); // ditto + - signals_.size() // return "parameters" don't have names + - methods.size(); // ditto QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data()); static_assert(QMetaObjectPrivate::OutputRevision == 10, "QtDBus meta-object generator should generate the same version as moc"); @@ -396,9 +396,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) header->className = 0; header->classInfoCount = 0; header->classInfoData = 0; - header->methodCount = int(signals_.count() + methods.count()); + header->methodCount = int(signals_.size() + methods.size()); header->methodData = int(idata.size()); - header->propertyCount = int(properties.count()); + header->propertyCount = int(properties.size()); header->propertyData = int(header->methodData + header->methodCount * QMetaObjectPrivate::IntsPerMethod + methodParametersDataSize); header->enumeratorCount = 0; @@ -406,7 +406,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) header->constructorCount = 0; header->constructorData = 0; header->flags = RequiresVariantMetaObject; - header->signalCount = signals_.count(); + header->signalCount = signals_.size(); // These are specific to QDBusMetaObject: header->propertyDBusData = int(header->propertyData + header->propertyCount * QMetaObjectPrivate::IntsPerProperty); @@ -416,9 +416,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) (header->methodCount * (QMetaObjectPrivate::IntsPerMethod+intsPerMethod)) + methodParametersDataSize + (header->propertyCount * (QMetaObjectPrivate::IntsPerProperty+intsPerProperty)); for (const Method &mm : qAsConst(signals_)) - data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); + data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size(); for (const Method &mm : qAsConst(methods)) - data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); + data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size(); idata.resize(data_size + 1); QMetaStringTable strings(className.toLatin1()); @@ -429,7 +429,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) qsizetype typeidOffset = header->methodDBusData + header->methodCount * intsPerMethod; idata[typeidOffset++] = 0; // eod - qsizetype totalMetaTypeCount = properties.count(); + qsizetype totalMetaTypeCount = properties.size(); ++totalMetaTypeCount; // + 1 for metatype of dynamic metaobject for (const auto& methodContainer: {signals_, methods}) { for (const auto& method: methodContainer) { @@ -441,7 +441,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) int propertyId = 0; // add each method: - qsizetype currentMethodMetaTypeOffset = properties.count() + 1; + qsizetype currentMethodMetaTypeOffset = properties.size() + 1; for (int x = 0; x < 2; ++x) { // Signals must be added before other methods, to match moc. QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods; @@ -494,14 +494,14 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) idata[parametersOffset++] = strings.enter(mm.parameterNames.at(i)); idata[signatureOffset++] = typeidOffset; - idata[typeidOffset++] = mm.inputTypes.count(); - memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int)); - typeidOffset += mm.inputTypes.count(); + idata[typeidOffset++] = mm.inputTypes.size(); + memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.size() * sizeof(int)); + typeidOffset += mm.inputTypes.size(); idata[signatureOffset++] = typeidOffset; - idata[typeidOffset++] = mm.outputTypes.count(); - memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int)); - typeidOffset += mm.outputTypes.count(); + idata[typeidOffset++] = mm.outputTypes.size(); + memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.size() * sizeof(int)); + typeidOffset += mm.outputTypes.size(); } } diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index b4cdb7ed8f..b1da47111e 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -52,7 +52,7 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo) if (interface.startsWith("QDBus"_L1)) { interface.prepend("org.qtproject.QtDBus."_L1); } else if (interface.startsWith(u'Q') && - interface.length() >= 2 && interface.at(1).isUpper()) { + interface.size() >= 2 && interface.at(1).isUpper()) { // assume it's Qt interface.prepend("org.qtproject.Qt."_L1); } else if (!QCoreApplication::instance()|| @@ -128,7 +128,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet if (type.endsWith('&')) { QByteArray basictype = type; - basictype.truncate(type.length() - 1); + basictype.truncate(type.size() - 1); QMetaType id = QMetaType::fromName(basictype); if (!id.isValid()) { diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 814cfa06b2..7674dd10f2 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -138,7 +138,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb // success // construct the expected signature - int count = metaTypes.count() - 1; + int count = metaTypes.size() - 1; if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) { // wildcard slot, can receive anything, so don't set the signature return true; diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index 5fa42d40b5..3b9e24eaf8 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -169,7 +169,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data return; } - if (reply.arguments().count() >= 1 && reply.arguments().at(0).metaType() == data.metaType()) { + if (reply.arguments().size() >= 1 && reply.arguments().at(0).metaType() == data.metaType()) { data = reply.arguments().at(0); return; } @@ -178,7 +178,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data const char *receivedType = nullptr; QByteArray receivedSignature; - if (reply.arguments().count() >= 1) { + if (reply.arguments().size() >= 1) { if (reply.arguments().at(0).metaType() == QDBusMetaTypeId::argument()) { // compare signatures instead QDBusArgument arg = qvariant_cast<QDBusArgument>(reply.arguments().at(0)); diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp index 4770d25e99..eb5aab4fd6 100644 --- a/src/dbus/qdbusutil.cpp +++ b/src/dbus/qdbusutil.cpp @@ -59,7 +59,7 @@ static bool variantToString(const QVariant &arg, QString &out) } else if (argType == QMetaType::QByteArray) { out += u'{'; QByteArray list = arg.toByteArray(); - for (int i = 0; i < list.length(); ++i) { + for (int i = 0; i < list.size(); ++i) { out += QString::number(list.at(i)); out += ", "_L1; } @@ -306,7 +306,7 @@ namespace QDBusUtil return false; // can't be valid if it's empty const QChar *c = part.data(); - for (int i = 0; i < part.length(); ++i) + for (int i = 0; i < part.size(); ++i) if (!isValidCharacterNoDash(c[i])) return false; @@ -335,11 +335,11 @@ namespace QDBusUtil */ bool isValidInterfaceName(const QString& ifaceName) { - if (ifaceName.isEmpty() || ifaceName.length() > DBUS_MAXIMUM_NAME_LENGTH) + if (ifaceName.isEmpty() || ifaceName.size() > DBUS_MAXIMUM_NAME_LENGTH) return false; const auto parts = QStringView{ifaceName}.split(u'.'); - if (parts.count() < 2) + if (parts.size() < 2) return false; // at least two parts for (auto part : parts) @@ -358,12 +358,12 @@ namespace QDBusUtil */ bool isValidUniqueConnectionName(QStringView connName) { - if (connName.isEmpty() || connName.length() > DBUS_MAXIMUM_NAME_LENGTH || + if (connName.isEmpty() || connName.size() > DBUS_MAXIMUM_NAME_LENGTH || !connName.startsWith(u':')) return false; const auto parts = connName.mid(1).split(u'.'); - if (parts.count() < 1) + if (parts.size() < 1) return false; for (QStringView part : parts) { @@ -371,7 +371,7 @@ namespace QDBusUtil return false; const QChar* c = part.data(); - for (int j = 0; j < part.length(); ++j) + for (int j = 0; j < part.size(); ++j) if (!isValidCharacter(c[j])) return false; } @@ -402,14 +402,14 @@ namespace QDBusUtil */ bool isValidBusName(const QString &busName) { - if (busName.isEmpty() || busName.length() > DBUS_MAXIMUM_NAME_LENGTH) + if (busName.isEmpty() || busName.size() > DBUS_MAXIMUM_NAME_LENGTH) return false; if (busName.startsWith(u':')) return isValidUniqueConnectionName(busName); const auto parts = QStringView{busName}.split(u'.'); - if (parts.count() < 1) + if (parts.size() < 1) return false; for (QStringView part : parts) { @@ -419,7 +419,7 @@ namespace QDBusUtil const QChar *c = part.data(); if (isValidNumber(c[0])) return false; - for (int j = 0; j < part.length(); ++j) + for (int j = 0; j < part.size(); ++j) if (!isValidCharacter(c[j])) return false; } @@ -435,13 +435,13 @@ namespace QDBusUtil */ bool isValidMemberName(QStringView memberName) { - if (memberName.isEmpty() || memberName.length() > DBUS_MAXIMUM_NAME_LENGTH) + if (memberName.isEmpty() || memberName.size() > DBUS_MAXIMUM_NAME_LENGTH) return false; const QChar* c = memberName.data(); if (isValidNumber(c[0])) return false; - for (int j = 0; j < memberName.length(); ++j) + for (int j = 0; j < memberName.size(); ++j) if (!isValidCharacterNoDash(c[j])) return false; return true; diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index f3a583dc22..662a96e53b 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -151,7 +151,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method qWarning() << "Skipped method" << mm.name() << ":" << qPrintable(errorMsg); continue; // invalid form } - if (isSignal && inputCount + 1 != types.count()) + if (isSignal && inputCount + 1 != types.size()) continue; // signal with output arguments? if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message()) continue; // signal with QDBusMessage argument? @@ -159,7 +159,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method continue; // cloned signal? int j; - for (j = 1; j < types.count(); ++j) { + for (j = 1; j < types.size(); ++j) { // input parameter for a slot or output for a signal if (types.at(j) == QDBusMetaTypeId::message()) { isScriptable = true; diff --git a/src/gui/accessible/linux/atspiadaptor.cpp b/src/gui/accessible/linux/atspiadaptor.cpp index c6905e8932..77e9510f44 100644 --- a/src/gui/accessible/linux/atspiadaptor.cpp +++ b/src/gui/accessible/linux/atspiadaptor.cpp @@ -935,14 +935,14 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) if (!textRemoved.isEmpty()) { data.setVariant(QVariant::fromValue(textRemoved)); - QVariantList args = packDBusSignalArguments("delete"_L1, changePosition, textRemoved.length(), QVariant::fromValue(data)); + QVariantList args = packDBusSignalArguments("delete"_L1, changePosition, textRemoved.size(), QVariant::fromValue(data)); sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT ""_L1, "TextChanged"_L1, args); } if (!textInserted.isEmpty()) { data.setVariant(QVariant::fromValue(textInserted)); - QVariantList args = packDBusSignalArguments("insert"_L1, changePosition, textInserted.length(), QVariant::fromValue(data)); + QVariantList args = packDBusSignalArguments("insert"_L1, changePosition, textInserted.size(), QVariant::fromValue(data)); sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT ""_L1, "TextChanged"_L1, args); } @@ -1656,12 +1656,12 @@ QRect AtSpiAdaptor::getExtents(QAccessibleInterface *interface, uint coordType) bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) { if (function == "GetNActions"_L1) { - int count = QAccessibleBridgeUtils::effectiveActionNames(interface).count(); + int count = QAccessibleBridgeUtils::effectiveActionNames(interface).size(); sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(count)))); } else if (function == "DoAction"_L1) { int index = message.arguments().at(0).toInt(); const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) + if (index < 0 || index >= actionNames.size()) return false; const QString actionName = actionNames.at(index); bool success = QAccessibleBridgeUtils::performEffectiveAction(interface, actionName); @@ -1671,13 +1671,13 @@ bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface, const QStrin } else if (function == "GetName"_L1) { int index = message.arguments().at(0).toInt(); const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) + if (index < 0 || index >= actionNames.size()) return false; sendReply(connection, message, actionNames.at(index)); } else if (function == "GetDescription"_L1) { int index = message.arguments().at(0).toInt(); const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) + if (index < 0 || index >= actionNames.size()) return false; QString description; if (QAccessibleActionInterface *actionIface = interface->actionInterface()) @@ -1688,7 +1688,7 @@ bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface, const QStrin } else if (function == "GetKeyBinding"_L1) { int index = message.arguments().at(0).toInt(); const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) + if (index < 0 || index >= actionNames.size()) return false; QStringList keyBindings; if (QAccessibleActionInterface *actionIface = interface->actionInterface()) @@ -1698,7 +1698,7 @@ bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface, const QStrin if (!acc.isEmpty()) keyBindings.append(acc); } - if (keyBindings.length() > 0) + if (keyBindings.size() > 0) sendReply(connection, message, keyBindings.join(u';')); else sendReply(connection, message, QString()); @@ -1904,13 +1904,13 @@ namespace QString atspiColor(const QString &ia2Color) { // "rgb(%u,%u,%u)" -> "%u,%u,%u" - return ia2Color.mid(4, ia2Color.length() - (4+1)); + return ia2Color.mid(4, ia2Color.size() - (4+1)); } QString atspiSize(const QString &ia2Size) { // "%fpt" -> "%f" - return ia2Size.left(ia2Size.length() - 2); + return ia2Size.left(ia2Size.size() - 2); } AtSpiAttribute atspiTextAttribute(const QString &ia2Name, const QString &ia2Value) @@ -2096,7 +2096,7 @@ static QString textForRange(QAccessibleInterface *accessible, int startOffset, i } QString txt = accessible->text(QAccessible::Value); if (endOffset == -1) - endOffset = txt.length(); + endOffset = txt.size(); return txt.mid(startOffset, endOffset - startOffset); } @@ -2104,7 +2104,7 @@ static void replaceTextFallback(QAccessibleInterface *accessible, long startOffs { QString t = textForRange(accessible, 0, -1); if (endOffset == -1) - endOffset = t.length(); + endOffset = t.size(); if (endOffset - startOffset == 0) t.insert(startOffset, txt); else diff --git a/src/gui/accessible/linux/qspiapplicationadaptor.cpp b/src/gui/accessible/linux/qspiapplicationadaptor.cpp index 1cac4598ca..963490d056 100644 --- a/src/gui/accessible/linux/qspiapplicationadaptor.cpp +++ b/src/gui/accessible/linux/qspiapplicationadaptor.cpp @@ -173,11 +173,11 @@ QKeyEvent* QSpiApplicationAdaptor::copyKeyEvent(QKeyEvent* old) void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& message) { - if (!keyEvents.length()) { + if (!keyEvents.size()) { qWarning("QSpiApplication::notifyKeyboardListenerCallback with no queued key called"); return; } - Q_ASSERT(message.arguments().length() == 1); + Q_ASSERT(message.arguments().size() == 1); if (message.arguments().at(0).toBool() == true) { QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); delete event.second; diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 286d27b15b..8af247bbdb 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -670,7 +670,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) const QString cn = QLatin1StringView(mo->className()); // Check if the class has a InterfaceFactory installed. - for (int i = qAccessibleFactories()->count(); i > 0; --i) { + for (int i = qAccessibleFactories()->size(); i > 0; --i) { InterfaceFactory factory = qAccessibleFactories()->at(i - 1); if (QAccessibleInterface *iface = factory(cn, object)) { QAccessibleCache::instance()->insert(object, iface); @@ -787,7 +787,7 @@ bool QAccessible::isActive() */ void QAccessible::setActive(bool active) { - for (int i = 0; i < qAccessibleActivationObservers()->count() ;++i) + for (int i = 0; i < qAccessibleActivationObservers()->size() ;++i) qAccessibleActivationObservers()->at(i)->accessibilityActiveChanged(active); } @@ -2008,7 +2008,7 @@ static QString textLineBoundary(int beforeAtAfter, const QString &text, int offs { Q_ASSERT(beforeAtAfter >= -1 && beforeAtAfter <= 1); Q_ASSERT(*startOffset == -1 && *endOffset == -1); - int length = text.length(); + int length = text.size(); Q_ASSERT(offset >= 0 && offset <= length); // move offset into the right range (if asking for line before or after @@ -2057,10 +2057,10 @@ QString QAccessibleTextInterface::textBeforeOffset(int offset, QAccessible::Text const QString txt = text(0, characterCount()); if (offset == -1) - offset = txt.length(); + offset = txt.size(); *startOffset = *endOffset = -1; - if (txt.isEmpty() || offset <= 0 || offset > txt.length()) + if (txt.isEmpty() || offset <= 0 || offset > txt.size()) return QString(); // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] @@ -2131,10 +2131,10 @@ QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible::TextB const QString txt = text(0, characterCount()); if (offset == -1) - offset = txt.length(); + offset = txt.size(); *startOffset = *endOffset = -1; - if (txt.isEmpty() || offset < 0 || offset >= txt.length()) + if (txt.isEmpty() || offset < 0 || offset >= txt.size()) return QString(); // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] @@ -2169,20 +2169,20 @@ QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible::TextB int toNext = boundary.toNextBoundary(); if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem))) break; - if (toNext < 0 || toNext >= txt.length()) + if (toNext < 0 || toNext >= txt.size()) break; // not found, the boundary might not exist } - Q_ASSERT(boundary.position() <= txt.length()); + Q_ASSERT(boundary.position() <= txt.size()); *startOffset = boundary.position(); while (true) { int toNext = boundary.toNextBoundary(); if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem))) break; - if (toNext < 0 || toNext >= txt.length()) + if (toNext < 0 || toNext >= txt.size()) break; // not found, the boundary might not exist } - Q_ASSERT(boundary.position() <= txt.length()); + Q_ASSERT(boundary.position() <= txt.size()); *endOffset = boundary.position(); if ((*startOffset == -1) || (*endOffset == -1) || (*startOffset == *endOffset)) { @@ -2216,13 +2216,13 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun const QString txt = text(0, characterCount()); if (offset == -1) - offset = txt.length(); + offset = txt.size(); *startOffset = *endOffset = -1; - if (txt.isEmpty() || offset < 0 || offset > txt.length()) + if (txt.isEmpty() || offset < 0 || offset > txt.size()) return QString(); - if (offset == txt.length() && boundaryType == QAccessible::CharBoundary) + if (offset == txt.size() && boundaryType == QAccessible::CharBoundary) return QString(); // type initialized just to silence a compiler warning [-Werror=maybe-uninitialized] @@ -2243,7 +2243,7 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun return textLineBoundary(0, txt, offset, startOffset, endOffset); case QAccessible::NoBoundary: *startOffset = 0; - *endOffset = txt.length(); + *endOffset = txt.size(); return txt; default: Q_UNREACHABLE(); @@ -2261,11 +2261,11 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun Q_ASSERT(boundary.position() >= 0); *startOffset = boundary.position(); - while (boundary.toNextBoundary() < txt.length()) { + while (boundary.toNextBoundary() < txt.size()) { if ((boundary.boundaryReasons() & (QTextBoundaryFinder::StartOfItem | QTextBoundaryFinder::EndOfItem))) break; } - Q_ASSERT(boundary.position() <= txt.length()); + Q_ASSERT(boundary.position() <= txt.size()); *endOffset = boundary.position(); return txt.mid(*startOffset, *endOffset - *startOffset); diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index b5e155c01e..6af8573c1d 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -409,13 +409,13 @@ class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEven { public: inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text) - : QAccessibleTextCursorEvent(obj, position + int(text.length())) + : QAccessibleTextCursorEvent(obj, position + int(text.size())) , m_position(position), m_text(text) { m_type = QAccessible::TextInserted; } inline QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text) - : QAccessibleTextCursorEvent(iface, position + int(text.length())) + : QAccessibleTextCursorEvent(iface, position + int(text.size())) , m_position(position), m_text(text) { m_type = QAccessible::TextInserted; @@ -469,13 +469,13 @@ class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEven { public: inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text) - : QAccessibleTextCursorEvent(obj, position + int(text.length())) + : QAccessibleTextCursorEvent(obj, position + int(text.size())) , m_position(position), m_oldText(oldText), m_text(text) { m_type = QAccessible::TextUpdated; } inline QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText, const QString &text) - : QAccessibleTextCursorEvent(iface, position + int(text.length())) + : QAccessibleTextCursorEvent(iface, position + int(text.size())) , m_position(position), m_oldText(oldText), m_text(text) { m_type = QAccessible::TextUpdated; diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index af9d3aa0fc..61d3a90632 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -124,7 +124,7 @@ static QObjectList topLevelObjects() { QObjectList list; const QWindowList tlw(QGuiApplication::topLevelWindows()); - for (int i = 0; i < tlw.count(); ++i) { + for (int i = 0; i < tlw.size(); ++i) { QWindow *w = tlw.at(i); if (w->type() != Qt::Popup && w->type() != Qt::Desktop) { if (QAccessibleInterface *root = w->accessibleRoot()) { @@ -140,7 +140,7 @@ static QObjectList topLevelObjects() /*! \reimp */ int QAccessibleApplication::childCount() const { - return topLevelObjects().count(); + return topLevelObjects().size(); } /*! \reimp */ @@ -160,7 +160,7 @@ QAccessibleInterface *QAccessibleApplication::parent() const QAccessibleInterface *QAccessibleApplication::child(int index) const { const QObjectList tlo(topLevelObjects()); - if (index >= 0 && index < tlo.count()) + if (index >= 0 && index < tlo.size()) return QAccessible::queryAccessibleInterface(tlo.at(index)); return nullptr; } diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp index 92936c74e6..ae7635ff7c 100644 --- a/src/gui/accessible/qplatformaccessibility.cpp +++ b/src/gui/accessible/qplatformaccessibility.cpp @@ -50,7 +50,7 @@ void QPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) if (!bridges() || bridges()->isEmpty()) return; - for (int i = 0; i < bridges()->count(); ++i) + for (int i = 0; i < bridges()->size(); ++i) bridges()->at(i)->notifyAccessibilityUpdate(event); } @@ -63,7 +63,7 @@ void QPlatformAccessibility::setRootObject(QObject *o) if (!o) return; - for (int i = 0; i < bridges()->count(); ++i) { + for (int i = 0; i < bridges()->size(); ++i) { QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); bridges()->at(i)->setRootObject(iface); } diff --git a/src/gui/image/qabstractfileiconengine.cpp b/src/gui/image/qabstractfileiconengine.cpp index e94451e4bb..ffbe088d20 100644 --- a/src/gui/image/qabstractfileiconengine.cpp +++ b/src/gui/image/qabstractfileiconengine.cpp @@ -61,7 +61,7 @@ QSize QAbstractFileIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) { const QList<QSize> &sizes = availableSizes(mode, state); - const int numberSizes = sizes.length(); + const int numberSizes = sizes.size(); if (numberSizes == 0) return QSize(); diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 08c4667c6c..8c2985e137 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -192,7 +192,7 @@ static QPixmapIconEngineEntry *bestSizeScaleMatch(const QSize &size, qreal scale QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state) { QPixmapIconEngineEntry *pe = nullptr; - for (int i = 0; i < pixmaps.count(); ++i) + for (int i = 0; i < pixmaps.size(); ++i) if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { if (pe) pe = bestSizeScaleMatch(size, scale, &pixmaps[i], pe); @@ -269,7 +269,7 @@ QPixmap QPixmapIconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIc pm = pe->pixmap; if (pm.isNull()) { - int idx = pixmaps.count(); + int idx = pixmaps.size(); while (--idx >= 0) { if (pe == &pixmaps.at(idx)) { pixmaps.remove(idx); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 6756826690..25ef2a4cfb 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -419,7 +419,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, if (cache->isValid()) { const QList<QIconDirInfo> subDirsCopy = subDirs; subDirs.clear(); - subDirs.reserve(result.count()); + subDirs.reserve(result.size()); for (const char *s : result) { QString path = QString::fromUtf8(s); auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(), diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index f50dd8bdb7..1d6e9fc15e 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1281,7 +1281,7 @@ bool QImageReader::read(QImage *image) static bool disableNxImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING"); if (!disableNxImageLoading) { const QByteArray suffix = QFileInfo(filename).baseName().right(3).toLatin1(); - if (suffix.length() == 3 && suffix[0] == '@' && suffix[1] >= '2' && suffix[1] <= '9' && suffix[2] == 'x') + if (suffix.size() == 3 && suffix[0] == '@' && suffix[1] >= '2' && suffix[1] <= '9' && suffix[2] == 'x') image->setDevicePixelRatio(suffix[1] - '0'); } if (autoTransform()) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index d8a7354e8f..c9b12c15f8 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -798,7 +798,7 @@ static void set_text(const QImage &image, png_structp png_ptr, png_infop info_pt int i = 0; while (it != text.constEnd()) { text_ptr[i].key = qstrdup(QStringView{it.key()}.left(79).toLatin1().constData()); - bool noCompress = (it.value().length() < 40); + bool noCompress = (it.value().size() < 40); #ifdef PNG_iTXt_SUPPORTED bool needsItxt = false; @@ -942,7 +942,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const iccProfileName.constData(), PNG_COMPRESSION_TYPE_BASE, (png_const_bytep)iccProfile.constData(), #endif - iccProfile.length()); + iccProfile.size()); } else #endif if (gamma != 0.0) { diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index c809b341f8..8eb88c1387 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -322,7 +322,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy switch (image.depth()) { case 1: { str.insert(1, '4'); - if (out->write(str, str.length()) != str.length()) + if (out->write(str, str.size()) != str.size()) return false; w = (w+7)/8; for (uint y=0; y<h; y++) { @@ -336,7 +336,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy case 8: { str.insert(1, gray ? '5' : '6'); str.append("255\n"); - if (out->write(str, str.length()) != str.length()) + if (out->write(str, str.size()) != str.size()) return false; qsizetype bpl = qsizetype(w) * (gray ? 1 : 3); uchar *buf = new uchar[bpl]; @@ -389,7 +389,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy case 32: { str.insert(1, '6'); str.append("255\n"); - if (out->write(str, str.length()) != str.length()) + if (out->write(str, str.size()) != str.size()) return false; qsizetype bpl = qsizetype(w) * 3; uchar *buf = new uchar[bpl]; diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index c3ab5fbb1d..e2248df6d7 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -164,7 +164,7 @@ static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const int h = image.height(); int i; QString s = fileName; // get file base name - int msize = s.length() + 100; + int msize = s.size() + 100; char *buf = new char[msize]; qsnprintf(buf, msize, "#define %s_width %d\n", s.toUtf8().data(), w); diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index aabee7fcd7..650160ba46 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -743,7 +743,7 @@ static QString fbname(const QString &fileName) // get file basename (sort of) ch.unicode() == '_'; }; int start = -1; - for (; i < s.length(); ++i) { + for (; i < s.size(); ++i) { if (isAsciiLetterOrNumber(s.at(i))) { start = i; } else if (start > 0) @@ -898,8 +898,8 @@ static bool read_xpm_body( } } else { QRgb c_rgb = 0; - if (((buf.length()-1) % 3) && (buf[0] == '#')) { - buf.truncate(((buf.length()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick + if (((buf.size()-1) % 3) && (buf[0] == '#')) { + buf.truncate(((buf.size()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick } if (buf[0] == '#') { c_rgb = qt_get_hex_rgb(buf).value_or(0); @@ -932,7 +932,7 @@ static bool read_xpm_body( if (image.depth() == 8) { uchar *p = image.scanLine(y); uchar *d = (uchar *)buf.data(); - uchar *end = d + buf.length(); + uchar *end = d + buf.size(); int x; if (cpp == 1) { char b[2]; @@ -958,7 +958,7 @@ static bool read_xpm_body( } else { QRgb *p = (QRgb*)image.scanLine(y); uchar *d = (uchar *)buf.data(); - uchar *end = d + buf.length(); + uchar *end = d + buf.size(); int x; char b[16]; b[cpp] = '\0'; diff --git a/src/gui/itemmodels/qfileinfogatherer.cpp b/src/gui/itemmodels/qfileinfogatherer.cpp index 10c36ea8dc..36b9587c1d 100644 --- a/src/gui/itemmodels/qfileinfogatherer.cpp +++ b/src/gui/itemmodels/qfileinfogatherer.cpp @@ -143,7 +143,7 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr void QFileInfoGatherer::updateFile(const QString &filePath) { QString dir = filePath.mid(0, filePath.lastIndexOf(u'/')); - QString fileName = filePath.mid(dir.length() + 1); + QString fileName = filePath.mid(dir.size() + 1); fetchExtendedInformation(dir, QStringList(fileName)); } @@ -340,13 +340,13 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil if (files.isEmpty()) { infoList = QDir::drives(); } else { - infoList.reserve(files.count()); + infoList.reserve(files.size()); for (const auto &file : files) infoList << QFileInfo(file); } QList<QPair<QString, QFileInfo>> updatedFiles; - updatedFiles.reserve(infoList.count()); - for (int i = infoList.count() - 1; i >= 0; --i) { + updatedFiles.reserve(infoList.size()); + for (int i = infoList.size() - 1; i >= 0; --i) { QFileInfo driveInfo = infoList.at(i); driveInfo.stat(); QString driveName = translateDriveName(driveInfo); @@ -394,7 +394,7 @@ void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bo updatedFiles.append(QPair<QString, QFileInfo>(fileInfo.fileName(), fileInfo)); QElapsedTimer current; current.start(); - if ((firstTime && updatedFiles.count() > 100) || base.msecsTo(current) > 1000) { + if ((firstTime && updatedFiles.size() > 100) || base.msecsTo(current) > 1000) { emit updates(path, updatedFiles); updatedFiles.clear(); base = current; diff --git a/src/gui/itemmodels/qfilesystemmodel.cpp b/src/gui/itemmodels/qfilesystemmodel.cpp index f0dcb6d801..1c0966e97e 100644 --- a/src/gui/itemmodels/qfilesystemmodel.cpp +++ b/src/gui/itemmodels/qfilesystemmodel.cpp @@ -394,12 +394,12 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS QFileSystemModelPrivate::QFileSystemNode *parent = node(index); - for (int i = 0; i < pathElements.count(); ++i) { + for (int i = 0; i < pathElements.size(); ++i) { QString element = pathElements.at(i); if (i != 0) elementPath.append(separator); elementPath.append(element); - if (i == pathElements.count() - 1) + if (i == pathElements.size() - 1) elementPath.append(trailingSeparator); #ifdef Q_OS_WIN // On Windows, "filename " and "filename" are equivalent and @@ -420,7 +420,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS // we couldn't find the path element, we create a new node since we // _know_ that the path is valid if (alreadyExisted) { - if ((parent->children.count() == 0) + if ((parent->children.size() == 0) || (parent->caseSensitive() && parent->children.value(element)->fileName != element) || (!parent->caseSensitive() @@ -476,7 +476,7 @@ void QFileSystemModel::timerEvent(QTimerEvent *event) if (event->timerId() == d->fetchingTimer.timerId()) { d->fetchingTimer.stop(); #if QT_CONFIG(filesystemwatcher) - for (int i = 0; i < d->toFetch.count(); ++i) { + for (int i = 0; i < d->toFetch.size(); ++i) { const QFileSystemModelPrivate::QFileSystemNode *node = d->toFetch.at(i).node; if (!node->hasInformation()) { d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir, @@ -640,10 +640,10 @@ int QFileSystemModel::rowCount(const QModelIndex &parent) const return 0; if (!parent.isValid()) - return d->root.visibleChildren.count(); + return d->root.visibleChildren.size(); const QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent); - return parentNode->visibleChildren.count(); + return parentNode->visibleChildren.size(); } /*! @@ -1058,7 +1058,7 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent { Q_Q(QFileSystemModel); QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent); - if (indexNode->children.count() == 0) + if (indexNode->children.size() == 0) return; QList<QFileSystemModelPrivate::QFileSystemNode *> values; @@ -1076,7 +1076,7 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent indexNode->visibleChildren.clear(); //No more dirty item we reset our internal dirty index indexNode->dirtyChildrenIndex = -1; - const int numValues = values.count(); + const int numValues = values.size(); indexNode->visibleChildren.reserve(numValues); for (int i = 0; i < numValues; ++i) { indexNode->visibleChildren.append(values.at(i)->fileName); @@ -1106,7 +1106,7 @@ void QFileSystemModel::sort(int column, Qt::SortOrder order) emit layoutAboutToBeChanged(); QModelIndexList oldList = persistentIndexList(); QList<QPair<QFileSystemModelPrivate::QFileSystemNode *, int>> oldNodes; - const int nodeCount = oldList.count(); + const int nodeCount = oldList.size(); oldNodes.reserve(nodeCount); for (int i = 0; i < nodeCount; ++i) { const QModelIndex &oldNode = oldList.at(i); @@ -1380,7 +1380,7 @@ QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const } QString fullPath = QDir::fromNativeSeparators(path.join(QDir::separator())); #if !defined(Q_OS_WIN) - if ((fullPath.length() > 2) && fullPath[0] == u'/' && fullPath[1] == u'/') + if ((fullPath.size() > 2) && fullPath[0] == u'/' && fullPath[1] == u'/') fullPath = fullPath.mid(1); #else if (fullPath.length() == 2 && fullPath.endsWith(u':')) @@ -1742,7 +1742,7 @@ bool QFileSystemModel::rmdir(const QModelIndex &aindex) void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, const QStringList &files) { QFileSystemModelPrivate::QFileSystemNode *parentNode = node(directory, false); - if (parentNode->children.count() == 0) + if (parentNode->children.size() == 0) return; QStringList toRemove; QStringList newFiles = files; @@ -1752,7 +1752,7 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons if ((iterator == newFiles.end()) || (i.value()->fileName < *iterator)) toRemove.append(i.value()->fileName); } - for (int i = 0 ; i < toRemove.count() ; ++i ) + for (int i = 0 ; i < toRemove.size() ; ++i ) removeNode(parentNode, toRemove[i]); } @@ -1844,11 +1844,11 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const QModelIndex parent = index(parentNode); bool indexHidden = isHiddenByFilter(parentNode, parent); if (!indexHidden) { - q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1); + q->beginInsertRows(parent, parentNode->visibleChildren.size() , parentNode->visibleChildren.size() + newFiles.size() - 1); } if (parentNode->dirtyChildrenIndex == -1) - parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count(); + parentNode->dirtyChildrenIndex = parentNode->visibleChildren.size(); for (const auto &newFile : newFiles) { parentNode->visibleChildren.append(newFile); @@ -1962,7 +1962,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, int visibleMin = parentNode->visibleLocation(min); int visibleMax = parentNode->visibleLocation(max); if (visibleMin >= 0 - && visibleMin < parentNode->visibleChildren.count() + && visibleMin < parentNode->visibleChildren.size() && parentNode->visibleChildren.at(visibleMin) == min && visibleMax >= 0) { QModelIndex bottom = q->index(translateVisibleLocation(parentNode, visibleMin), 0, parentIndex); @@ -1974,11 +1974,11 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, max = QString();*/ } - if (newFiles.count() > 0) { + if (newFiles.size() > 0) { addVisibleFiles(parentNode, newFiles); } - if (newFiles.count() > 0 || (sortColumn != 0 && rowsToUpdate.count() > 0)) { + if (newFiles.size() > 0 || (sortColumn != 0 && rowsToUpdate.size() > 0)) { forceSort = true; delayedSort(); } diff --git a/src/gui/itemmodels/qfilesystemmodel_p.h b/src/gui/itemmodels/qfilesystemmodel_p.h index fa83208936..62a23205e4 100644 --- a/src/gui/itemmodels/qfilesystemmodel_p.h +++ b/src/gui/itemmodels/qfilesystemmodel_p.h @@ -92,7 +92,7 @@ public: inline bool isDir() const { if (info) return info->isDir(); - if (children.count() > 0) + if (children.size() > 0) return true; return false; } @@ -209,7 +209,7 @@ public: inline int translateVisibleLocation(QFileSystemNode *parent, int row) const { if (sortOrder != Qt::AscendingOrder) { if (parent->dirtyChildrenIndex == -1) - return parent->visibleChildren.count() - row - 1; + return parent->visibleChildren.size() - row - 1; if (row < parent->dirtyChildrenIndex) return parent->dirtyChildrenIndex - row - 1; diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index bfb5e8e134..c5e1c42707 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -319,11 +319,11 @@ void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order) } QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo; - QList<QStandardItem*> sorted_children(children.count()); + QList<QStandardItem*> sorted_children(children.size()); for (int i = 0; i < rowCount(); ++i) { - int r = (i < sortable.count() + int r = (i < sortable.size() ? sortable.at(i).second - : unsortable.at(i - sortable.count())); + : unsortable.at(i - sortable.size())); for (int c = 0; c < columnCount(); ++c) { QStandardItem *itm = q->child(r, c); sorted_children[childIndex(i, c)] = itm; @@ -371,7 +371,7 @@ void QStandardItemPrivate::setModel(QStandardItemModel *mod) } itm->d_func()->model = mod; const QList<QStandardItem*> &childList = itm->d_func()->children; - for (int i = 0; i < childList.count(); ++i) { + for (int i = 0; i < childList.size(); ++i) { QStandardItem *chi = childList.at(i); if (chi) stack.push(chi); @@ -432,7 +432,7 @@ bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &item Q_Q(QStandardItem); if ((row < 0) || (row > rowCount()) || items.isEmpty()) return false; - int count = items.count(); + int count = items.size(); if (model) model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); if (rowCount() == 0) { @@ -446,7 +446,7 @@ bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &item if (index != -1) children.insert(index, columnCount() * count, nullptr); } - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { QStandardItem *item = items.at(i); item->d_func()->model = model; item->d_func()->parent = q; @@ -478,7 +478,7 @@ bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardI } if (!items.isEmpty()) { int index = childIndex(row, 0); - int limit = qMin(items.count(), columnCount() * count); + int limit = qMin(items.size(), columnCount() * count); for (int i = 0; i < limit; ++i) { QStandardItem *item = items.at(i); if (item) { @@ -523,7 +523,7 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QSta } } if (!items.isEmpty()) { - int limit = qMin(items.count(), rowCount() * count); + int limit = qMin(items.size(), rowCount() * count); for (int i = 0; i < limit; ++i) { QStandardItem *item = items.at(i); if (item) { @@ -1588,8 +1588,8 @@ void QStandardItem::insertRow(int row, const QList<QStandardItem*> &items) Q_D(QStandardItem); if (row < 0) return; - if (columnCount() < items.count()) - setColumnCount(items.count()); + if (columnCount() < items.size()) + setColumnCount(items.size()); d->insertRows(row, 1, items); } @@ -1617,8 +1617,8 @@ void QStandardItem::insertColumn(int column, const QList<QStandardItem*> &items) Q_D(QStandardItem); if (column < 0) return; - if (rowCount() < items.count()) - setRowCount(items.count()); + if (rowCount() < items.size()) + setRowCount(items.size()); d->insertColumns(column, 1, items); } @@ -2529,9 +2529,9 @@ QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels) { Q_D(QStandardItemModel); - if (columnCount() < labels.count()) - setColumnCount(labels.count()); - for (int i = 0; i < labels.count(); ++i) { + if (columnCount() < labels.size()) + setColumnCount(labels.size()); + for (int i = 0; i < labels.size(); ++i) { QStandardItem *item = horizontalHeaderItem(i); if (!item) { item = d->createItem(); @@ -2552,9 +2552,9 @@ void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels) void QStandardItemModel::setVerticalHeaderLabels(const QStringList &labels) { Q_D(QStandardItemModel); - if (rowCount() < labels.count()) - setRowCount(labels.count()); - for (int i = 0; i < labels.count(); ++i) { + if (rowCount() < labels.size()) + setRowCount(labels.size()); + for (int i = 0; i < labels.size(); ++i) { QStandardItem *item = verticalHeaderItem(i); if (!item) { item = d->createItem(); @@ -3112,9 +3112,9 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const QSet<QStandardItem*> itemsSet; QStack<QStandardItem*> stack; - itemsSet.reserve(indexes.count()); - stack.reserve(indexes.count()); - for (int i = 0; i < indexes.count(); ++i) { + itemsSet.reserve(indexes.size()); + stack.reserve(indexes.size()); + for (int i = 0; i < indexes.size(); ++i) { if (QStandardItem *item = itemFromIndex(indexes.at(i))) { itemsSet << item; stack.push(item); @@ -3133,7 +3133,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const continue; const QList<QStandardItem*> &childList = itm->d_func()->children; - for (int i = 0; i < childList.count(); ++i) { + for (int i = 0; i < childList.size(); ++i) { QStandardItem *chi = childList.at(i); if (chi) { itemsSet.remove(chi); @@ -3143,7 +3143,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const } } - stack.reserve(itemsSet.count()); + stack.reserve(itemsSet.size()); for (QStandardItem *item : qAsConst(itemsSet)) stack.push(item); @@ -3153,7 +3153,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position stream << item->row() << item->column(); - stream << *item << item->columnCount() << int(item->d_ptr->children.count()); + stream << *item << item->columnCount() << int(item->d_ptr->children.size()); stack += item->d_ptr->children; } @@ -3242,15 +3242,15 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti // Compute the number of continuous rows upon insertion and modify the rows to match QList<int> rowsToInsert(bottom + 1); - for (int i = 0; i < rows.count(); ++i) + for (int i = 0; i < rows.size(); ++i) rowsToInsert[rows.at(i)] = 1; - for (int i = 0; i < rowsToInsert.count(); ++i) { + for (int i = 0; i < rowsToInsert.size(); ++i) { if (rowsToInsert.at(i) == 1){ rowsToInsert[i] = dragRowCount; ++dragRowCount; } } - for (int i = 0; i < rows.count(); ++i) + for (int i = 0; i < rows.size(); ++i) rows[i] = top + rowsToInsert.at(rows.at(i)); QBitArray isWrittenTo(dragRowCount * dragColumnCount); diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 6e9b2e21d8..8b76777d93 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -74,7 +74,7 @@ public: return pointingDevice() ? pointingDevice()->pointerType() : QPointingDevice::PointerType::Unknown; } void setTimestamp(quint64 timestamp) override; - qsizetype pointCount() const { return m_points.count(); } + qsizetype pointCount() const { return m_points.size(); } QEventPoint &point(qsizetype i); const QList<QEventPoint> &points() const { return m_points; } QEventPoint *pointById(int id); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index da513408db..16803f4d14 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -867,7 +867,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking return false; } - for (int i = 0; i < modalWindowList.count(); ++i) { + for (int i = 0; i < modalWindowList.size(); ++i) { QWindow *modalWindow = modalWindowList.at(i); // A window is not blocked by another modal window if the two are @@ -1298,7 +1298,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString static void init_plugins(const QList<QByteArray> &pluginList) { - for (int i = 0; i < pluginList.count(); ++i) { + for (int i = 0; i < pluginList.size(); ++i) { QByteArray pluginSpec = pluginList.at(i); int colonPos = pluginSpec.indexOf(':'); QObject *plugin; @@ -1676,7 +1676,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() is_app_closing = true; is_app_running = false; - for (int i = 0; i < generic_plugin_list.count(); ++i) + for (int i = 0; i < generic_plugin_list.size(); ++i) delete generic_plugin_list.at(i); generic_plugin_list.clear(); diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 8d6bb62594..a6e4bdad2d 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -489,7 +489,7 @@ void QHighDpiScaling::updateHighDpiScaling() for (const auto &[name, factor] : m_screenFactors) { ++i; if (name.isNull()) { - if (i < screens.count()) + if (i < screens.size()) setScreenFactor(screens.at(i), factor); } else { for (QScreen *screen : screens) { diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index c415a95ab9..c6a20736fc 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -947,7 +947,7 @@ QKeySequence QKeySequence::mnemonic(const QString &text) int p = 0; while (p >= 0) { p = text.indexOf(u'&', p) + 1; - if (p <= 0 || p >= (int)text.length()) + if (p <= 0 || p >= (int)text.size()) break; if (text.at(p) != u'&') { QChar c = text.at(p); @@ -1001,13 +1001,13 @@ int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format) // Run through the whole string, but stop // if we have MaxKeyCount keys before the end. - while (keyseq.length() && n < QKeySequencePrivate::MaxKeyCount) { + while (keyseq.size() && n < QKeySequencePrivate::MaxKeyCount) { // We MUST use something to separate each sequence, and space // does not cut it, since some of the key names have space // in them.. (Let's hope no one translate with a comma in it:) p = keyseq.indexOf(u','); if (-1 != p) { - if (p == keyseq.length() - 1) { // Last comma 'Ctrl+,' + if (p == keyseq.size() - 1) { // Last comma 'Ctrl+,' p = -1; } else { if (u',' == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,' @@ -1020,8 +1020,8 @@ int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format) } } } - QString part = keyseq.left(-1 == p ? keyseq.length() : p - diff); - keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1)); + QString part = keyseq.left(-1 == p ? keyseq.size() : p - diff); + keyseq = keyseq.right(-1 == p ? 0 : keyseq.size() - (p + 1)); d->key[n] = QKeySequencePrivate::decodeString(std::move(part), format); ++n; } @@ -1128,9 +1128,9 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma // except for a single '+' at the end of the string. // Only '+' can have length 1. - if (sub.length() == 1) { + if (sub.size() == 1) { // Make sure we only encounter a single '+' at the end of the accel - if (accel.lastIndexOf(u'+') != accel.length()-1) + if (accel.lastIndexOf(u'+') != accel.size()-1) return Qt::Key_unknown; } else { // Identify the modifier @@ -1150,13 +1150,13 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma lastI = i + 1; } - int p = accel.lastIndexOf(u'+', accel.length() - 2); // -2 so that Ctrl++ works + int p = accel.lastIndexOf(u'+', accel.size() - 2); // -2 so that Ctrl++ works QStringView accelRef(accel); if (p > 0) accelRef = accelRef.mid(p + 1); int fnum = 0; - if (accelRef.length() == 1) { + if (accelRef.size() == 1) { #if defined(Q_OS_MACOS) int qtKey = qtkeyForMacSymbol(accelRef.at(0)); if (qtKey != -1) { @@ -1524,7 +1524,7 @@ QString QKeySequence::toString(SequenceFormat format) const finalString += d->encodeString(d->key[i], format); finalString += ", "_L1; } - finalString.truncate(finalString.length() - 2); + finalString.truncate(finalString.size() - 2); return finalString; } @@ -1553,7 +1553,7 @@ QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFor QList<QKeySequence> result; const QStringList strings = str.split("; "_L1); - result.reserve(strings.count()); + result.reserve(strings.size()); for (const QString &string : strings) { result << fromString(string, format); } @@ -1577,7 +1577,7 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm result += sequence.toString(format); result += "; "_L1; } - result.truncate(result.length() - 2); + result.truncate(result.size() - 2); return result; } diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp index d1caf59ee0..f890fc1ca8 100644 --- a/src/gui/kernel/qpointingdevice.cpp +++ b/src/gui/kernel/qpointingdevice.cpp @@ -319,7 +319,7 @@ const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& sea QInputDevicePrivate::registerDevice(mouse); return mouse; } - if (v.length() > 1) + if (v.size() > 1) qCDebug(lcQpaInputDevices) << "core pointer ambiguous for seat" << seatName; if (mouse) return mouse; diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 2b22816e3e..45be27de64 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -413,7 +413,7 @@ QList<QScreen *> QScreen::virtualSiblings() const Q_D(const QScreen); const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings(); QList<QScreen *> screens; - screens.reserve(platformScreens.count()); + screens.reserve(platformScreens.size()); for (QPlatformScreen *platformScreen : platformScreens) screens << platformScreen->screen(); return screens; diff --git a/src/gui/kernel/qshortcut.cpp b/src/gui/kernel/qshortcut.cpp index eccbb5b873..3cd4f10ddc 100644 --- a/src/gui/kernel/qshortcut.cpp +++ b/src/gui/kernel/qshortcut.cpp @@ -133,7 +133,7 @@ void QShortcutPrivate::redoGrab(QShortcutMap &map) sc_ids.clear(); if (sc_sequences.isEmpty()) return; - sc_ids.reserve(sc_sequences.count()); + sc_ids.reserve(sc_sequences.size()); for (const auto &keySequence : qAsConst(sc_sequences)) { if (keySequence.isEmpty()) continue; diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index b643393430..ffe39e5c0d 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -305,7 +305,7 @@ bool QShortcutMap::tryShortcut(QKeyEvent *e) case QKeySequence::ExactMatch: { // Save number of identical matches before dispatching // to keep QShortcutMap and tryShortcut reentrant. - const int identicalMatches = d->identicals.count(); + const int identicalMatches = d->identicals.size(); resetState(); dispatchEvent(e); // If there are no identicals we've only found disabled shortcuts, and @@ -389,7 +389,7 @@ bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifiers) { Q_D(QShortcutMap); - if (!d->sequences.count()) + if (!d->sequences.size()) return QKeySequence::NoMatch; createNewSequences(e, d->newEntries, ignoredModifiers); @@ -397,7 +397,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier // Should never happen if (d->newEntries == d->currentSequences) { - Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().length(), + Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().size(), "QShortcutMap::find", "New sequence to find identical to previous"); return QKeySequence::NoMatch; } @@ -409,7 +409,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier bool identicalDisabledFound = false; QList<QKeySequence> okEntries; int result = QKeySequence::NoMatch; - for (int i = d->newEntries.count()-1; i >= 0 ; --i) { + for (int i = d->newEntries.size()-1; i >= 0 ; --i) { QShortcutEntry entry(d->newEntries.at(i)); // needed for searching const auto itEnd = d->sequences.constEnd(); auto it = std::lower_bound(d->sequences.constBegin(), itEnd, entry); @@ -491,11 +491,11 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, in QList<int> possibleKeys = QKeyMapper::possibleKeys(e); qCDebug(lcShortcutMap) << "Creating new sequences for" << e << "with ignoredModifiers=" << Qt::KeyboardModifiers(ignoredModifiers); - int pkTotal = possibleKeys.count(); + int pkTotal = possibleKeys.size(); if (!pkTotal) return; - int ssActual = d->currentSequences.count(); + int ssActual = d->currentSequences.size(); int ssTotal = qMax(1, ssActual); // Resize to possible permutations of the current sequence(s). ksl.resize(pkTotal * ssTotal); diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 71cf3f0439..e410edaad9 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -35,7 +35,7 @@ Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd") static QWindow* topLevelAt(const QPoint &pos) { QWindowList list = QGuiApplication::topLevelWindows(); - for (int i = list.count()-1; i >= 0; --i) { + for (int i = list.size()-1; i >= 0; --i) { QWindow *w = list.at(i); if (w->isVisible() && w->handle() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w)) return w; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 07879b36bf..5e96879644 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -644,7 +644,7 @@ QList<QEventPoint> QList<QEventPoint> touchPoints; QEventPoint::States states; - touchPoints.reserve(points.count()); + touchPoints.reserve(points.size()); QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin(); QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd(); while (point != end) { diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 58f786b153..27aa7dbc57 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -464,7 +464,7 @@ public: void append(WindowSystemEvent *e) { const QMutexLocker locker(&mutex); impl.append(e); } int count() const - { const QMutexLocker locker(&mutex); return impl.count(); } + { const QMutexLocker locker(&mutex); return impl.size(); } WindowSystemEvent *peekAtFirstOfType(EventType t) const { const QMutexLocker locker(&mutex); diff --git a/src/gui/painting/qbackingstoredefaultcompositor.cpp b/src/gui/painting/qbackingstoredefaultcompositor.cpp index 4b27aeb247..076ae3e984 100644 --- a/src/gui/painting/qbackingstoredefaultcompositor.cpp +++ b/src/gui/painting/qbackingstoredefaultcompositor.cpp @@ -148,7 +148,7 @@ static QRegion scaledRegion(const QRegion ®ion, qreal factor, const QPoint &o rects.append(scaledRect(rect.translated(offset), factor)); QRegion deviceRegion; - deviceRegion.setRects(rects.constData(), rects.count()); + deviceRegion.setRects(rects.constData(), rects.size()); return deviceRegion; } @@ -517,7 +517,7 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo } const int textureWidgetCount = textures->count(); - const int oldTextureQuadDataCount = m_textureQuadData.count(); + const int oldTextureQuadDataCount = m_textureQuadData.size(); if (oldTextureQuadDataCount != textureWidgetCount) { for (int i = textureWidgetCount; i < oldTextureQuadDataCount; ++i) m_textureQuadData[i].reset(); diff --git a/src/gui/painting/qcolortransfertable_p.h b/src/gui/painting/qcolortransfertable_p.h index 4563acf1fa..dc0f5804fd 100644 --- a/src/gui/painting/qcolortransfertable_p.h +++ b/src/gui/painting/qcolortransfertable_p.h @@ -35,12 +35,12 @@ public: QColorTransferTable(uint32_t size, const QList<uint8_t> &table) noexcept : m_tableSize(size), m_table8(table) { - Q_ASSERT(qsizetype(size) <= table.count()); + Q_ASSERT(qsizetype(size) <= table.size()); } QColorTransferTable(uint32_t size, const QList<uint16_t> &table) noexcept : m_tableSize(size), m_table16(table) { - Q_ASSERT(qsizetype(size) <= table.count()); + Q_ASSERT(qsizetype(size) <= table.size()); } bool isEmpty() const diff --git a/src/gui/painting/qpageranges.cpp b/src/gui/painting/qpageranges.cpp index 7d62c7c321..500673b22f 100644 --- a/src/gui/painting/qpageranges.cpp +++ b/src/gui/painting/qpageranges.cpp @@ -14,7 +14,7 @@ QT_IMPL_METATYPE_EXTERN(QPageRanges) void QPageRangesPrivate::mergeIntervals() { - const int count = intervals.count(); + const int count = intervals.size(); if (count <= 1) return; @@ -162,7 +162,7 @@ QPageRanges QPageRanges::fromString(const QString &ranges) if (item.contains(u'-')) { const QStringList rangeItems = item.split(u'-'); - if (rangeItems.count() != 2) + if (rangeItems.size() != 2) return QPageRanges(); bool ok; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 13a1cd5437..1a2dbb6a9f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4269,7 +4269,7 @@ protected: void QGradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, int opacity) const { const QGradientStops stops = gradient.stops(); - int stopCount = stops.count(); + int stopCount = stops.size(); Q_ASSERT(stopCount > 0); bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 0ccfccb19e..a424954ad4 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5591,7 +5591,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif } engine.itemize(); QScriptLine line; - line.length = str.length(); + line.length = str.size(); engine.shapeLine(line); int nItems = engine.layoutData->items.size(); @@ -5646,7 +5646,7 @@ void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br Q_D(QPainter); - if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) + if (!d->engine || str.size() == 0 || pen().style() == Qt::NoPen) return; if (!d->extended) @@ -5733,7 +5733,7 @@ void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF * Q_D(QPainter); - if (!d->engine || str.length() == 0 || pen().style() == Qt::NoPen) + if (!d->engine || str.size() == 0 || pen().style() == Qt::NoPen) return; if (!d->extended) @@ -5852,7 +5852,7 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption Q_D(QPainter); - if (!d->engine || text.length() == 0 || pen().style() == Qt::NoPen) + if (!d->engine || text.size() == 0 || pen().style() == Qt::NoPen) return; if (!d->extended) @@ -6343,7 +6343,7 @@ QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextO { Q_D(QPainter); - if (!d->engine || text.length() == 0) + if (!d->engine || text.size() == 0) return QRectF(r.x(),r.y(), 0,0); QRectF br; @@ -7133,7 +7133,7 @@ start_lengthVariant: // compatible behaviour to the old implementation. Replace // tabs by spaces int old_offset = offset; - for (; offset < text.length(); offset++) { + for (; offset < text.size(); offset++) { QChar chr = text.at(offset); if (chr == u'\r' || (singleline && chr == u'\n')) { text[offset] = u' '; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index c1fa060793..848769d5b2 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1938,7 +1938,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) addXrefEntry(toUnicode); QByteArray touc = font->createToUnicodeMap(); xprintf("<< /Length %d >>\n" - "stream\n", touc.length()); + "stream\n", touc.size()); write(touc); write("\nendstream\n" "endobj\n"); @@ -2334,7 +2334,7 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, //qDebug("DCT"); xprintf("/Filter /DCTDecode\n>>\nstream\n"); write(data); - len = data.length(); + len = data.size(); } else { if (do_compress) xprintf("/Filter /FlateDecode\n>>\nstream\n"); @@ -2665,7 +2665,7 @@ int QPdfEnginePrivate::gradientBrush(const QBrush &b, const QTransform &matrix, "/Shading << /Shader" << alphaShaderObject << alphaShaderObject << "0 R >>\n" ">>\n"; - f << "/Length " << content.length() << "\n" + f << "/Length " << content.size() << "\n" ">>\n" "stream\n" << content @@ -2783,7 +2783,7 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, s << "/XObject << /Im" << imageObject << ' ' << imageObject << "0 R >> "; } s << ">>\n" - "/Length " << pattern.length() << "\n" + "/Length " << pattern.size() << "\n" ">>\n" "stream\n" << pattern diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 92a848e0d1..4c6a570e76 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -293,7 +293,7 @@ private: } int writeCompressed(const char *src, int len); - inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); } + inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.size()); } int writeCompressed(QIODevice *dev); struct AttachmentInfo diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index befd3a4197..8a23003065 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -68,7 +68,7 @@ QPlatformTextureList::~QPlatformTextureList() int QPlatformTextureList::count() const { Q_D(const QPlatformTextureList); - return d->textures.count(); + return d->textures.size(); } QRhiTexture *QPlatformTextureList::texture(int index) const diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index 99d67599ed..a3a89d7504 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -421,7 +421,7 @@ QDebug operator<<(QDebug dbg, const QPolygon &a) { QDebugStateSaver saver(dbg); dbg.nospace() << "QPolygon("; - for (int i = 0; i < a.count(); ++i) + for (int i = 0; i < a.size(); ++i) dbg.nospace() << a.at(i); dbg.nospace() << ')'; return dbg; @@ -742,7 +742,7 @@ QDebug operator<<(QDebug dbg, const QPolygonF &a) { QDebugStateSaver saver(dbg); dbg.nospace() << "QPolygonF("; - for (int i = 0; i < a.count(); ++i) + for (int i = 0; i < a.size(); ++i) dbg.nospace() << a.at(i); dbg.nospace() << ')'; return dbg; diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 7d912b29e5..3504e44d1d 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3818,7 +3818,7 @@ QRegion::QRegion(const QRect &r, RegionType t) QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) { - if (a.count() > 2) { + if (a.size() > 2) { QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); if (qt_rgn) { diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 5fa5d04e54..61d78fb607 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1459,7 +1459,7 @@ QRegion QTransform::map(const QRegion &r) const if (!nr.isEmpty()) rects.append(nr); } - res.setRects(rects.constData(), rects.count()); + res.setRects(rects.constData(), rects.size()); } return res; } @@ -1706,7 +1706,7 @@ QPolygon QTransform::mapToPolygon(const QRect &rect) const */ bool QTransform::squareToQuad(const QPolygonF &quad, QTransform &trans) { - if (quad.count() != 4) + if (quad.size() != 4) return false; qreal dx0 = quad[0].x(); diff --git a/src/gui/platform/unix/dbusmenu/qdbusmenuregistrarproxy_p.h b/src/gui/platform/unix/dbusmenu/qdbusmenuregistrarproxy_p.h index 4568fd2aa4..8041f3af0a 100644 --- a/src/gui/platform/unix/dbusmenu/qdbusmenuregistrarproxy_p.h +++ b/src/gui/platform/unix/dbusmenu/qdbusmenuregistrarproxy_p.h @@ -63,7 +63,7 @@ public Q_SLOTS: // METHODS { QDBusMessage reply = call(QDBus::Block, QStringLiteral("GetMenuForWindow"), windowId); QList<QVariant> arguments = reply.arguments(); - if (reply.type() == QDBusMessage::ReplyMessage && arguments.count() == 2) + if (reply.type() == QDBusMessage::ReplyMessage && arguments.size() == 2) menuObjectPath = qdbus_cast<QDBusObjectPath>(arguments.at(1)); return reply; } diff --git a/src/gui/platform/unix/dbusmenu/qdbusmenutypes.cpp b/src/gui/platform/unix/dbusmenu/qdbusmenutypes.cpp index f70ce67d4e..d2469a0d26 100644 --- a/src/gui/platform/unix/dbusmenu/qdbusmenutypes.cpp +++ b/src/gui/platform/unix/dbusmenu/qdbusmenutypes.cpp @@ -204,7 +204,7 @@ QString QDBusMenuItem::convertMnemonic(const QString &label) // convert only the first occurrence of ampersand which is not at the end // dbusmenu uses underscore instead of ampersand int idx = label.indexOf(u'&'); - if (idx < 0 || idx == label.length() - 1) + if (idx < 0 || idx == label.size() - 1) return label; QString ret(label); ret[idx] = u'_'; @@ -271,7 +271,7 @@ QDebug operator<<(QDebug d, const QDBusMenuLayoutItem &item) { QDebugStateSaver saver(d); d.nospace(); - d << "QDBusMenuLayoutItem(id=" << item.m_id << ", properties=" << item.m_properties << ", " << item.m_children.count() << " children)"; + d << "QDBusMenuLayoutItem(id=" << item.m_id << ", properties=" << item.m_properties << ", " << item.m_children.size() << " children)"; return d; } #endif diff --git a/src/gui/platform/unix/dbustray/qxdgnotificationproxy_p.h b/src/gui/platform/unix/dbustray/qxdgnotificationproxy_p.h index fe61723bd2..dfbc64f33b 100644 --- a/src/gui/platform/unix/dbustray/qxdgnotificationproxy_p.h +++ b/src/gui/platform/unix/dbustray/qxdgnotificationproxy_p.h @@ -77,7 +77,7 @@ public Q_SLOTS: // METHODS inline QDBusReply<QString> getServerInformation(QString &vendor, QString &version, QString &specVersion) { QDBusMessage reply = call(QDBus::Block, QStringLiteral("GetServerInformation")); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 4) { + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().size() == 4) { vendor = qdbus_cast<QString>(reply.arguments().at(1)); version = qdbus_cast<QString>(reply.arguments().at(2)); specVersion = qdbus_cast<QString>(reply.arguments().at(3)); diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index a1abdffd32..4de24da883 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4963,7 +4963,7 @@ QRhiImplementation::~QRhiImplementation() if (!resources.isEmpty()) { if (leakCheck) { qWarning("QRhi %p going down with %d unreleased resources that own native graphics objects. This is not nice.", - q, int(resources.count())); + q, int(resources.size())); } for (QRhiResource *res : qAsConst(resources)) { if (leakCheck) @@ -6018,7 +6018,7 @@ QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch() QRhiResourceUpdateBatch *u = nextFreeBatch(); if (!u) { - const int oldSize = d->resUpdPool.count(); + const int oldSize = d->resUpdPool.size(); const int newSize = oldSize + qMin(4, qMax(0, 64 - oldSize)); d->resUpdPool.resize(newSize); for (int i = oldSize; i < newSize; ++i) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index a12a0b551e..5522169ab3 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -920,7 +920,7 @@ void QRhiGles2::destroy() void QRhiGles2::executeDeferredReleases() { - for (int i = releaseQueue.count() - 1; i >= 0; --i) { + for (int i = releaseQueue.size() - 1; i >= 0; --i) { const QRhiGles2::DeferredReleaseEntry &e(releaseQueue[i]); switch (e.type) { case QRhiGles2::DeferredReleaseEntry::Buffer: @@ -1344,8 +1344,8 @@ QByteArray QRhiGles2::pipelineCacheData() memset(&header, 0, sizeof(header)); header.rhiId = pipelineCacheRhiId(); header.arch = quint32(sizeof(void*)); - header.programBinaryCount = m_pipelineCache.count(); - const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.length())); + header.programBinaryCount = m_pipelineCache.size(); + const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.size())); if (driverStrLen) memcpy(header.driver, driverInfoStruct.deviceName.constData(), driverStrLen); header.driver[driverStrLen] = '\0'; @@ -1417,7 +1417,7 @@ void QRhiGles2::setPipelineCacheData(const QByteArray &data) if (header.programBinaryCount == 0) return; - const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.length())); + const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.size())); if (strncmp(header.driver, driverInfoStruct.deviceName.constData(), driverStrLen)) { qWarning("setPipelineCacheData: OpenGL vendor/renderer/version does not match"); return; @@ -1452,7 +1452,7 @@ void QRhiGles2::setPipelineCacheData(const QByteArray &data) m_pipelineCache.insert(key, { format, data }); } - qCDebug(QRHI_LOG_INFO, "Seeded pipeline cache with %d program binaries", int(m_pipelineCache.count())); + qCDebug(QRHI_LOG_INFO, "Seeded pipeline cache with %d program binaries", int(m_pipelineCache.size())); } QRhiRenderBuffer *QRhiGles2::createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, @@ -1534,7 +1534,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, srb); if (cbD->passNeedsResourceTracking) { QRhiPassResourceTracker &passResTracker(cbD->passResTrackers[cbD->currentPassResTrackerIndex]); - for (int i = 0, ie = srbD->m_bindings.count(); i != ie; ++i) { + for (int i = 0, ie = srbD->m_bindings.size(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); switch (b->type) { case QRhiShaderResourceBinding::UniformBuffer: @@ -2254,7 +2254,7 @@ void QRhiGles2::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate const QRhiResourceUpdateBatchPrivate::TextureOp &u(ud->textureOps[opIdx]); if (u.type == QRhiResourceUpdateBatchPrivate::TextureOp::Upload) { QGles2Texture *texD = QRHI_RES(QGles2Texture, u.dst); - for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { + for (int layer = 0, maxLayer = u.subresDesc.size(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) enqueueSubresUpload(texD, cbD, layer, level, subresDesc); @@ -3586,7 +3586,7 @@ void QRhiGles2::bindShaderResources(QGles2CommandBuffer *cbD, }; QVarLengthArray<SeparateSampler, 4> separateSamplerBindings; - for (int i = 0, ie = srbD->m_bindings.count(); i != ie; ++i) { + for (int i = 0, ie = srbD->m_bindings.size(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); switch (b->type) { @@ -3990,7 +3990,7 @@ QGles2RenderTargetData *QRhiGles2::enqueueBindFramebuffer(QRhiRenderTarget *rt, void QRhiGles2::enqueueBarriersForPass(QGles2CommandBuffer *cbD) { cbD->passResTrackers.append(QRhiPassResourceTracker()); - cbD->currentPassResTrackerIndex = cbD->passResTrackers.count() - 1; + cbD->currentPassResTrackerIndex = cbD->passResTrackers.size() - 1; QGles2CommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QGles2CommandBuffer::Command::BarriersForPass; cmd.args.barriersForPass.trackerIndex = cbD->currentPassResTrackerIndex; @@ -4168,7 +4168,7 @@ void QRhiGles2::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) accessAndIsNewFlag = { 0, false }; QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, cbD->currentComputeSrb); - const int bindingCount = srbD->m_bindings.count(); + const int bindingCount = srbD->m_bindings.size(); for (int i = 0; i < bindingCount; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); switch (b->type) { @@ -4329,7 +4329,7 @@ bool QRhiGles2::compileShader(GLuint program, const QRhiShaderStage &shaderStage } else { shader = f->glCreateShader(toGlShaderType(shaderStage.type())); const char *srcStr = source.constData(); - const GLint srcLength = source.length(); + const GLint srcLength = source.size(); f->glShaderSource(shader, 1, &srcStr, &srcLength); f->glCompileShader(shader); GLint compiled = 0; @@ -4346,7 +4346,7 @@ bool QRhiGles2::compileShader(GLuint program, const QRhiShaderStage &shaderStage qWarning("Failed to compile shader: %s\nSource was:\n%s", log.constData(), source.constData()); return false; } - if (m_shaderCache.count() >= MAX_SHADER_CACHE_ENTRIES) { + if (m_shaderCache.size() >= MAX_SHADER_CACHE_ENTRIES) { // Use the simplest strategy: too many cached shaders -> drop them all. for (uint shader : m_shaderCache) f->glDeleteShader(shader); // does not actually get released yet when attached to a not-yet-released program @@ -4403,7 +4403,7 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable // unnecessary glUniform* calls then. uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); if (uniform.glslLocation >= 0 && !activeUniformLocations->hasSeen(uniform.glslLocation)) { - if (var.arrayDims.count() > 1) { + if (var.arrayDims.size() > 1) { qWarning("Array '%s' has more than one dimension. This is not supported.", var.name.constData()); return; @@ -4432,7 +4432,7 @@ void QRhiGles2::gatherUniforms(GLuint program, registerUniformIfActive(structMember, structPrefix + ".", ub.binding, baseOffset, program, activeUniformLocations, dst); } else { - if (blockMember.arrayDims.count() > 1) { + if (blockMember.arrayDims.size() > 1) { qWarning("Array of struct '%s' has more than one dimension. Only the first " "dimension is used.", blockMember.name.constData()); @@ -5392,7 +5392,7 @@ bool QGles2ShaderResourceBindings::create() return false; hasDynamicOffset = false; - for (int i = 0, ie = m_bindings.count(); i != ie; ++i) { + for (int i = 0, ie = m_bindings.size(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = m_bindings.at(i).data(); if (b->type == QRhiShaderResourceBinding::UniformBuffer) { if (b->u.ubuf.hasDynamicOffset) { @@ -5515,7 +5515,7 @@ bool QGles2GraphicsPipeline::create() QByteArray cacheKey; QRhiGles2::ProgramCacheResult cacheResult = rhiD->tryLoadFromDiskOrPipelineCache(m_shaderStages.constData(), - m_shaderStages.count(), + m_shaderStages.size(), program, desc[VtxIdx].inputVariables(), &cacheKey); diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 2a3412a69c..d0a7faaffc 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -382,7 +382,7 @@ QRhi::FrameOpResult QRhiNull::finish() void QRhiNull::simulateTextureUpload(const QRhiResourceUpdateBatchPrivate::TextureOp &u) { QNullTexture *texD = QRHI_RES(QNullTexture, u.dst); - for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { + for (int layer = 0, maxLayer = u.subresDesc.size(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) { if (!subresDesc.image().isNull()) { diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index fd1ede2424..31bdd20fcc 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -486,7 +486,7 @@ bool QRhiVulkan::create(QRhi::Flags flags) gfxQueueFamilyIdx = -1; int computelessGfxQueueCandidateIdx = -1; queryQueueFamilyProps(); - for (int i = 0; i < queueFamilyProps.count(); ++i) { + for (int i = 0; i < queueFamilyProps.size(); ++i) { qCDebug(QRHI_LOG_INFO, "queue family %d: flags=0x%x count=%d", i, queueFamilyProps[i].queueFlags, queueFamilyProps[i].queueCount); if (gfxQueueFamilyIdx == -1 @@ -529,7 +529,7 @@ bool QRhiVulkan::create(QRhi::Flags flags) for (const VkExtensionProperties &p : qAsConst(extProps)) devExts.append({ p.extensionName, p.specVersion }); } - qCDebug(QRHI_LOG_INFO, "%d device extensions available", int(devExts.count())); + qCDebug(QRHI_LOG_INFO, "%d device extensions available", int(devExts.size())); QList<const char *> requestedDevExts; requestedDevExts.append("VK_KHR_swapchain"); @@ -594,9 +594,9 @@ bool QRhiVulkan::create(QRhi::Flags flags) devInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; devInfo.queueCreateInfoCount = 1; devInfo.pQueueCreateInfos = queueInfo; - devInfo.enabledLayerCount = uint32_t(devLayers.count()); + devInfo.enabledLayerCount = uint32_t(devLayers.size()); devInfo.ppEnabledLayerNames = devLayers.constData(); - devInfo.enabledExtensionCount = uint32_t(requestedDevExts.count()); + devInfo.enabledExtensionCount = uint32_t(requestedDevExts.size()); devInfo.ppEnabledExtensionNames = requestedDevExts.constData(); // Enable all 1.0 core features that are reported as supported, except @@ -846,7 +846,7 @@ bool QRhiVulkan::allocateDescriptorSet(VkDescriptorSetAllocateInfo *allocInfo, V return r; }; - int lastPoolIdx = descriptorPools.count() - 1; + int lastPoolIdx = descriptorPools.size() - 1; for (int i = lastPoolIdx; i >= 0; --i) { if (descriptorPools[i].refCount == 0) { df->vkResetDescriptorPool(dev, descriptorPools[i].pool, 0); @@ -866,7 +866,7 @@ bool QRhiVulkan::allocateDescriptorSet(VkDescriptorSetAllocateInfo *allocInfo, V VkResult poolErr = createDescriptorPool(&newPool); if (poolErr == VK_SUCCESS) { descriptorPools.append(newPool); - lastPoolIdx = descriptorPools.count() - 1; + lastPoolIdx = descriptorPools.size() - 1; VkResult err = tryAllocate(lastPoolIdx); if (err != VK_SUCCESS) { qWarning("Failed to allocate descriptor set from new pool too, giving up: %d", err); @@ -1187,18 +1187,18 @@ static void fillRenderPassCreateInfo(VkRenderPassCreateInfo *rpInfo, { memset(subpassDesc, 0, sizeof(VkSubpassDescription)); subpassDesc->pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpassDesc->colorAttachmentCount = uint32_t(rpD->colorRefs.count()); + subpassDesc->colorAttachmentCount = uint32_t(rpD->colorRefs.size()); subpassDesc->pColorAttachments = !rpD->colorRefs.isEmpty() ? rpD->colorRefs.constData() : nullptr; subpassDesc->pDepthStencilAttachment = rpD->hasDepthStencil ? &rpD->dsRef : nullptr; subpassDesc->pResolveAttachments = !rpD->resolveRefs.isEmpty() ? rpD->resolveRefs.constData() : nullptr; memset(rpInfo, 0, sizeof(VkRenderPassCreateInfo)); rpInfo->sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - rpInfo->attachmentCount = uint32_t(rpD->attDescs.count()); + rpInfo->attachmentCount = uint32_t(rpD->attDescs.size()); rpInfo->pAttachments = rpD->attDescs.constData(); rpInfo->subpassCount = 1; rpInfo->pSubpasses = subpassDesc; - rpInfo->dependencyCount = uint32_t(rpD->subpassDeps.count()); + rpInfo->dependencyCount = uint32_t(rpD->subpassDeps.size()); rpInfo->pDependencies = !rpD->subpassDeps.isEmpty() ? rpD->subpassDeps.constData() : nullptr; } @@ -1321,7 +1321,7 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.size() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; rpD->colorRefs.append(ref); } @@ -1345,7 +1345,7 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; rpD->attDescs.append(attDesc); } - rpD->dsRef = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; + rpD->dsRef = { uint32_t(rpD->attDescs.size() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { if (it->resolveTexture()) { @@ -1377,14 +1377,14 @@ bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.size() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; rpD->resolveRefs.append(ref); } else { const VkAttachmentReference ref = { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; rpD->resolveRefs.append(ref); } } - Q_ASSERT(rpD->colorRefs.count() == rpD->resolveRefs.count()); + Q_ASSERT(rpD->colorRefs.size() == rpD->resolveRefs.size()); // rpD->subpassDeps stays empty: don't yet know the correct initial/final // access and stage stuff for the implicit deps at this point, so leave it @@ -1806,7 +1806,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin // when profiling is enabled, pick a free query (pair) from the pool int timestampQueryIdx = -1; if (hasGpuFrameTimeCallback() && swapChainD->bufferCount > 1) { // no timestamps if not having at least 2 frames in flight - for (int i = 0; i < timestampQueryPoolMap.count(); ++i) { + for (int i = 0; i < timestampQueryPoolMap.size(); ++i) { if (!timestampQueryPoolMap.testBit(i)) { timestampQueryPoolMap.setBit(i); timestampQueryIdx = i * 2; @@ -2380,14 +2380,14 @@ void QRhiVulkan::beginPass(QRhiCommandBuffer *cb, float(colorClearValue.alphaF()) } }; cvs.append(cv); } - rpBeginInfo.clearValueCount = uint32_t(cvs.count()); + rpBeginInfo.clearValueCount = uint32_t(cvs.size()); QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::BeginRenderPass; cmd.args.beginRenderPass.desc = rpBeginInfo; - cmd.args.beginRenderPass.clearValueIndex = cbD->pools.clearValue.count(); + cmd.args.beginRenderPass.clearValueIndex = cbD->pools.clearValue.size(); cmd.args.beginRenderPass.useSecondaryCb = cbD->passUsesSecondaryCb; - cbD->pools.clearValue.append(cvs.constData(), cvs.count()); + cbD->pools.clearValue.append(cvs.constData(), cvs.size()); if (cbD->passUsesSecondaryCb) cbD->activeSecondaryCbStack.append(startSecondaryCommandBuffer(rtD)); @@ -2518,7 +2518,7 @@ void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) accessAndIsNewFlag = { 0, false }; QVkShaderResourceBindings *srbD = QRHI_RES(QVkShaderResourceBindings, cbD->currentComputeSrb); - const int bindingCount = srbD->m_bindings.count(); + const int bindingCount = srbD->m_bindings.size(); for (int i = 0; i < bindingCount; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); switch (b->type) { @@ -2598,12 +2598,12 @@ void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, - imageBarriers.count(), imageBarriers.constData()); + imageBarriers.size(), imageBarriers.constData()); } if (!bufferBarriers.isEmpty()) { df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, - bufferBarriers.count(), bufferBarriers.constData(), + bufferBarriers.size(), bufferBarriers.constData(), 0, nullptr); } df->vkCmdDispatch(secondaryCb, uint32_t(x), uint32_t(y), uint32_t(z)); @@ -2613,18 +2613,18 @@ void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; cmd.args.imageBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; cmd.args.imageBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; - cmd.args.imageBarrier.count = imageBarriers.count(); - cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); - cbD->pools.imageBarrier.append(imageBarriers.constData(), imageBarriers.count()); + cmd.args.imageBarrier.count = imageBarriers.size(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.size(); + cbD->pools.imageBarrier.append(imageBarriers.constData(), imageBarriers.size()); } if (!bufferBarriers.isEmpty()) { QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::BufferBarrier; cmd.args.bufferBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; cmd.args.bufferBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; - cmd.args.bufferBarrier.count = bufferBarriers.count(); - cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); - cbD->pools.bufferBarrier.append(bufferBarriers.constData(), bufferBarriers.count()); + cmd.args.bufferBarrier.count = bufferBarriers.size(); + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.size(); + cbD->pools.bufferBarrier.append(bufferBarriers.constData(), bufferBarriers.size()); } QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::Dispatch; @@ -2681,7 +2681,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i const bool updateAll = descSetIdx < 0; int frameSlot = updateAll ? 0 : descSetIdx; while (frameSlot < (updateAll ? QVK_FRAMES_IN_FLIGHT : descSetIdx + 1)) { - for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) { + for (int i = 0, ie = srbD->sortedBindings.size(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data(); QVkShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[frameSlot][i]); @@ -2710,7 +2710,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i bufInfo.range = VkDeviceSize(b->u.ubuf.maybeSize ? b->u.ubuf.maybeSize : bufD->m_size); // be nice and assert when we know the vulkan device would die a horrible death due to non-aligned reads Q_ASSERT(aligned(bufInfo.offset, ubufAlign) == bufInfo.offset); - bufferInfoIndex = bufferInfos.count(); + bufferInfoIndex = bufferInfos.size(); bufferInfos.append(bufInfo); } break; @@ -2732,7 +2732,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i imageInfo[elem].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } bd.stex.count = data->count; - imageInfoIndex = imageInfos.count(); + imageInfoIndex = imageInfos.size(); imageInfos.append(imageInfo); } break; @@ -2753,7 +2753,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i imageInfo[elem].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } bd.stex.count = data->count; - imageInfoIndex = imageInfos.count(); + imageInfoIndex = imageInfos.size(); imageInfos.append(imageInfo); } break; @@ -2769,7 +2769,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i imageInfo[0].sampler = samplerD->sampler; imageInfo[0].imageView = VK_NULL_HANDLE; imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_GENERAL; - imageInfoIndex = imageInfos.count(); + imageInfoIndex = imageInfos.size(); imageInfos.append(imageInfo); } break; @@ -2787,7 +2787,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i imageInfo[0].sampler = VK_NULL_HANDLE; imageInfo[0].imageView = view; imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_GENERAL; - imageInfoIndex = imageInfos.count(); + imageInfoIndex = imageInfos.size(); imageInfos.append(imageInfo); } } @@ -2804,7 +2804,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i bufInfo.buffer = bufD->m_type == QRhiBuffer::Dynamic ? bufD->buffers[frameSlot] : bufD->buffers[0]; bufInfo.offset = VkDeviceSize(b->u.ubuf.offset); bufInfo.range = VkDeviceSize(b->u.ubuf.maybeSize ? b->u.ubuf.maybeSize : bufD->m_size); - bufferInfoIndex = bufferInfos.count(); + bufferInfoIndex = bufferInfos.size(); bufferInfos.append(bufInfo); } break; @@ -2818,7 +2818,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i ++frameSlot; } - for (int i = 0, writeInfoCount = writeInfos.count(); i < writeInfoCount; ++i) { + for (int i = 0, writeInfoCount = writeInfos.size(); i < writeInfoCount; ++i) { const int bufferInfoIndex = infoIndices[i].first; const int imageInfoIndex = infoIndices[i].second; if (bufferInfoIndex >= 0) @@ -2827,7 +2827,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i writeInfos[i].pImageInfo = imageInfos[imageInfoIndex].constData(); } - df->vkUpdateDescriptorSets(dev, uint32_t(writeInfos.count()), writeInfos.constData(), 0, nullptr); + df->vkUpdateDescriptorSets(dev, uint32_t(writeInfos.size()), writeInfos.constData(), 0, nullptr); } static inline bool accessIsWrite(VkAccessFlags access) @@ -2874,7 +2874,7 @@ void QRhiVulkan::trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, in cmd.args.bufferBarrier.srcStageMask = s.stage; cmd.args.bufferBarrier.dstStageMask = stage; cmd.args.bufferBarrier.count = 1; - cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.size(); cbD->pools.bufferBarrier.append(bufMemBarrier); s.access = access; @@ -2916,7 +2916,7 @@ void QRhiVulkan::trackedImageBarrier(QVkCommandBuffer *cbD, QVkTexture *texD, cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = stage; cmd.args.imageBarrier.count = 1; - cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.size(); cbD->pools.imageBarrier.append(barrier); s.layout = layout; @@ -2951,7 +2951,7 @@ void QRhiVulkan::depthStencilExplicitBarrier(QVkCommandBuffer *cbD, QVkRenderBuf cmd.args.imageBarrier.srcStageMask = stages; cmd.args.imageBarrier.dstStageMask = stages; cmd.args.imageBarrier.count = 1; - cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.size(); cbD->pools.imageBarrier.append(barrier); } @@ -2982,7 +2982,7 @@ void QRhiVulkan::subresourceBarrier(QVkCommandBuffer *cbD, VkImage image, cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = dstStage; cmd.args.imageBarrier.count = 1; - cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.size(); cbD->pools.imageBarrier.append(barrier); } @@ -3261,7 +3261,7 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat QVkTexture *utexD = QRHI_RES(QVkTexture, u.dst); // batch into a single staging buffer and a single CopyBufferToImage with multiple copyInfos VkDeviceSize stagingSize = 0; - for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { + for (int layer = 0, maxLayer = u.subresDesc.size(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { for (const QRhiTextureSubresourceUploadDescription &subresDesc : qAsConst(u.subresDesc[layer][level])) stagingSize += subresUploadByteSize(subresDesc); @@ -3298,7 +3298,7 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat continue; } - for (int layer = 0, maxLayer = u.subresDesc.count(); layer < maxLayer; ++layer) { + for (int layer = 0, maxLayer = u.subresDesc.size(); layer < maxLayer; ++layer) { for (int level = 0; level < QRhi::MAX_MIP_LEVELS; ++level) { const QList<QRhiTextureSubresourceUploadDescription> &srd(u.subresDesc[layer][level]); if (srd.isEmpty()) @@ -3320,9 +3320,9 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat cmd.args.copyBufferToImage.src = utexD->stagingBuffers[currentFrameSlot]; cmd.args.copyBufferToImage.dst = utexD->image; cmd.args.copyBufferToImage.dstLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - cmd.args.copyBufferToImage.count = copyInfos.count(); - cmd.args.copyBufferToImage.bufferImageCopyIndex = cbD->pools.bufferImageCopy.count(); - cbD->pools.bufferImageCopy.append(copyInfos.constData(), copyInfos.count()); + cmd.args.copyBufferToImage.count = copyInfos.size(); + cmd.args.copyBufferToImage.bufferImageCopyIndex = cbD->pools.bufferImageCopy.size(); + cbD->pools.bufferImageCopy.append(copyInfos.constData(), copyInfos.size()); // no reuse of staging, this is intentional QRhiVulkan::DeferredReleaseEntry e; @@ -3661,7 +3661,7 @@ static void qrhivk_releaseSampler(const QRhiVulkan::DeferredReleaseEntry &e, VkD void QRhiVulkan::executeDeferredReleases(bool forced) { - for (int i = releaseQueue.count() - 1; i >= 0; --i) { + for (int i = releaseQueue.size() - 1; i >= 0; --i) { const QRhiVulkan::DeferredReleaseEntry &e(releaseQueue[i]); if (forced || currentFrameSlot == e.lastActiveFrameSlot || e.lastActiveFrameSlot < 0) { switch (e.type) { @@ -3717,7 +3717,7 @@ void QRhiVulkan::finishActiveReadbacks(bool forced) { QVarLengthArray<std::function<void()>, 4> completedCallbacks; - for (int i = activeTextureReadbacks.count() - 1; i >= 0; --i) { + for (int i = activeTextureReadbacks.size() - 1; i >= 0; --i) { const QRhiVulkan::TextureReadback &readback(activeTextureReadbacks[i]); if (forced || currentFrameSlot == readback.activeFrameSlot || readback.activeFrameSlot < 0) { readback.result->format = readback.format; @@ -3742,7 +3742,7 @@ void QRhiVulkan::finishActiveReadbacks(bool forced) } } - for (int i = activeBufferReadbacks.count() - 1; i >= 0; --i) { + for (int i = activeBufferReadbacks.size() - 1; i >= 0; --i) { const QRhiVulkan::BufferReadback &readback(activeBufferReadbacks[i]); if (forced || currentFrameSlot == readback.activeFrameSlot || readback.activeFrameSlot < 0) { VmaAllocation a = toVmaAllocation(readback.stagingAlloc); @@ -3825,11 +3825,11 @@ VkSampleCountFlagBits QRhiVulkan::effectiveSampleCount(int sampleCount) void QRhiVulkan::enqueueTransitionPassResources(QVkCommandBuffer *cbD) { cbD->passResTrackers.append(QRhiPassResourceTracker()); - cbD->currentPassResTrackerIndex = cbD->passResTrackers.count() - 1; + cbD->currentPassResTrackerIndex = cbD->passResTrackers.size() - 1; QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::TransitionPassResources; - cmd.args.transitionResources.trackerIndex = cbD->passResTrackers.count() - 1; + cmd.args.transitionResources.trackerIndex = cbD->passResTrackers.size() - 1; } void QRhiVulkan::recordPrimaryCommandBuffer(QVkCommandBuffer *cbD) @@ -4633,7 +4633,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin // Do host writes and mark referenced shader resources as in-use. // Also prepare to ensure the descriptor set we are going to bind refers to up-to-date Vk objects. - for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) { + for (int i = 0, ie = srbD->sortedBindings.size(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings[i].data(); QVkShaderResourceBindings::BoundResourceData &bd(descSetBd[i]); switch (b->type) { @@ -4801,8 +4801,8 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin gfxPsD ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_COMPUTE, gfxPsD ? gfxPsD->layout : compPsD->layout, 0, 1, &srbD->descSets[descSetIdx], - uint32_t(dynOfs.count()), - dynOfs.count() ? dynOfs.constData() : nullptr); + uint32_t(dynOfs.size()), + dynOfs.size() ? dynOfs.constData() : nullptr); } else { QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::BindDescriptorSet; @@ -4810,9 +4810,9 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin : VK_PIPELINE_BIND_POINT_COMPUTE; cmd.args.bindDescriptorSet.pipelineLayout = gfxPsD ? gfxPsD->layout : compPsD->layout; cmd.args.bindDescriptorSet.descSet = srbD->descSets[descSetIdx]; - cmd.args.bindDescriptorSet.dynamicOffsetCount = dynOfs.count(); - cmd.args.bindDescriptorSet.dynamicOffsetIndex = cbD->pools.dynamicOffset.count(); - cbD->pools.dynamicOffset.append(dynOfs.constData(), dynOfs.count()); + cmd.args.bindDescriptorSet.dynamicOffsetCount = dynOfs.size(); + cmd.args.bindDescriptorSet.dynamicOffsetIndex = cbD->pools.dynamicOffset.size(); + cbD->pools.dynamicOffset.append(dynOfs.constData(), dynOfs.size()); } if (gfxPsD) { @@ -4871,16 +4871,16 @@ void QRhiVulkan::setVertexInput(QRhiCommandBuffer *cb, if (cbD->passUsesSecondaryCb) { df->vkCmdBindVertexBuffers(cbD->activeSecondaryCbStack.last(), uint32_t(startBinding), - uint32_t(bufs.count()), bufs.constData(), ofs.constData()); + uint32_t(bufs.size()), bufs.constData(), ofs.constData()); } else { QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::BindVertexBuffer; cmd.args.bindVertexBuffer.startBinding = startBinding; - cmd.args.bindVertexBuffer.count = bufs.count(); - cmd.args.bindVertexBuffer.vertexBufferIndex = cbD->pools.vertexBuffer.count(); - cbD->pools.vertexBuffer.append(bufs.constData(), bufs.count()); - cmd.args.bindVertexBuffer.vertexBufferOffsetIndex = cbD->pools.vertexBufferOffset.count(); - cbD->pools.vertexBufferOffset.append(ofs.constData(), ofs.count()); + cmd.args.bindVertexBuffer.count = bufs.size(); + cmd.args.bindVertexBuffer.vertexBufferIndex = cbD->pools.vertexBuffer.size(); + cbD->pools.vertexBuffer.append(bufs.constData(), bufs.size()); + cmd.args.bindVertexBuffer.vertexBufferOffsetIndex = cbD->pools.vertexBufferOffset.size(); + cbD->pools.vertexBufferOffset.append(ofs.constData(), ofs.size()); } } @@ -5079,7 +5079,7 @@ void QRhiVulkan::debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::DebugMarkerBegin; cmd.args.debugMarkerBegin.marker = marker; - cmd.args.debugMarkerBegin.markerNameIndex = cbD->pools.debugMarkerData.count(); + cmd.args.debugMarkerBegin.markerNameIndex = cbD->pools.debugMarkerData.size(); cbD->pools.debugMarkerData.append(name); } } @@ -5115,7 +5115,7 @@ void QRhiVulkan::debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) QVkCommandBuffer::Command &cmd(cbD->commands.get()); cmd.cmd = QVkCommandBuffer::Command::DebugMarkerInsert; cmd.args.debugMarkerInsert.marker = marker; - cmd.args.debugMarkerInsert.markerNameIndex = cbD->pools.debugMarkerData.count(); + cmd.args.debugMarkerInsert.markerNameIndex = cbD->pools.debugMarkerData.size(); cbD->pools.debugMarkerData.append(msg); } } @@ -6321,16 +6321,16 @@ bool QVkRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other const QVkRenderPassDescriptor *o = QRHI_RES(const QVkRenderPassDescriptor, other); - if (attDescs.count() != o->attDescs.count()) + if (attDescs.size() != o->attDescs.size()) return false; - if (colorRefs.count() != o->colorRefs.count()) + if (colorRefs.size() != o->colorRefs.size()) return false; - if (resolveRefs.count() != o->resolveRefs.count()) + if (resolveRefs.size() != o->resolveRefs.size()) return false; if (hasDepthStencil != o->hasDepthStencil) return false; - for (int i = 0, ie = colorRefs.count(); i != ie; ++i) { + for (int i = 0, ie = colorRefs.size(); i != ie; ++i) { const uint32_t attIdx = colorRefs[i].attachment; if (attIdx != o->colorRefs[i].attachment) return false; @@ -6346,7 +6346,7 @@ bool QVkRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other return false; } - for (int i = 0, ie = resolveRefs.count(); i != ie; ++i) { + for (int i = 0, ie = resolveRefs.size(); i != ie; ++i) { const uint32_t attIdx = resolveRefs[i].attachment; if (attIdx != o->resolveRefs[i].attachment) return false; @@ -6364,9 +6364,9 @@ void QVkRenderPassDescriptor::updateSerializedFormat() serializedFormatData.clear(); auto p = std::back_inserter(serializedFormatData); - *p++ = attDescs.count(); - *p++ = colorRefs.count(); - *p++ = resolveRefs.count(); + *p++ = attDescs.size(); + *p++ = colorRefs.size(); + *p++ = resolveRefs.size(); *p++ = hasDepthStencil; auto serializeAttachmentData = [this, &p](uint32_t attIdx) { @@ -6382,7 +6382,7 @@ void QVkRenderPassDescriptor::updateSerializedFormat() *p++ = used ? a->finalLayout : 0; }; - for (int i = 0, ie = colorRefs.count(); i != ie; ++i) { + for (int i = 0, ie = colorRefs.size(); i != ie; ++i) { const uint32_t attIdx = colorRefs[i].attachment; *p++ = attIdx; serializeAttachmentData(attIdx); @@ -6394,7 +6394,7 @@ void QVkRenderPassDescriptor::updateSerializedFormat() serializeAttachmentData(attIdx); } - for (int i = 0, ie = resolveRefs.count(); i != ie; ++i) { + for (int i = 0, ie = resolveRefs.size(); i != ie; ++i) { const uint32_t attIdx = resolveRefs[i].attachment; *p++ = attIdx; serializeAttachmentData(attIdx); @@ -6783,7 +6783,7 @@ bool QVkShaderResourceBindings::create() VkDescriptorSetLayoutCreateInfo layoutInfo; memset(&layoutInfo, 0, sizeof(layoutInfo)); layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - layoutInfo.bindingCount = uint32_t(vkbindings.count()); + layoutInfo.bindingCount = uint32_t(vkbindings.size()); layoutInfo.pBindings = vkbindings.constData(); VkResult err = rhiD->df->vkCreateDescriptorSetLayout(rhiD->dev, &layoutInfo, nullptr, &layout); @@ -6804,7 +6804,7 @@ bool QVkShaderResourceBindings::create() return false; for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) { - boundResourceData[i].resize(sortedBindings.count()); + boundResourceData[i].resize(sortedBindings.size()); for (BoundResourceData &bd : boundResourceData[i]) memset(&bd, 0, sizeof(BoundResourceData)); } @@ -6837,7 +6837,7 @@ void QVkShaderResourceBindings::updateResources(UpdateFlags flags) // complicating the checks in setShaderResources(), reset the table here // just like we do in create(). for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) { - Q_ASSERT(boundResourceData[i].count() == sortedBindings.count()); + Q_ASSERT(boundResourceData[i].size() == sortedBindings.size()); for (BoundResourceData &bd : boundResourceData[i]) memset(&bd, 0, sizeof(BoundResourceData)); } @@ -6927,7 +6927,7 @@ bool QVkGraphicsPipeline::create() shaderStageCreateInfos.append(shaderInfo); } } - pipelineInfo.stageCount = uint32_t(shaderStageCreateInfos.count()); + pipelineInfo.stageCount = uint32_t(shaderStageCreateInfos.size()); pipelineInfo.pStages = shaderStageCreateInfos.constData(); QVarLengthArray<VkVertexInputBindingDescription, 4> vertexBindings; @@ -6968,15 +6968,15 @@ bool QVkGraphicsPipeline::create() VkPipelineVertexInputStateCreateInfo vertexInputInfo; memset(&vertexInputInfo, 0, sizeof(vertexInputInfo)); vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - vertexInputInfo.vertexBindingDescriptionCount = uint32_t(vertexBindings.count()); + vertexInputInfo.vertexBindingDescriptionCount = uint32_t(vertexBindings.size()); vertexInputInfo.pVertexBindingDescriptions = vertexBindings.constData(); - vertexInputInfo.vertexAttributeDescriptionCount = uint32_t(vertexAttributes.count()); + vertexInputInfo.vertexAttributeDescriptionCount = uint32_t(vertexAttributes.size()); vertexInputInfo.pVertexAttributeDescriptions = vertexAttributes.constData(); VkPipelineVertexInputDivisorStateCreateInfoEXT divisorInfo; if (!nonOneStepRates.isEmpty()) { memset(&divisorInfo, 0, sizeof(divisorInfo)); divisorInfo.sType = VkStructureType(1000190001); // VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT - divisorInfo.vertexBindingDivisorCount = uint32_t(nonOneStepRates.count()); + divisorInfo.vertexBindingDivisorCount = uint32_t(nonOneStepRates.size()); divisorInfo.pVertexBindingDivisors = nonOneStepRates.constData(); vertexInputInfo.pNext = &divisorInfo; } @@ -6993,7 +6993,7 @@ bool QVkGraphicsPipeline::create() VkPipelineDynamicStateCreateInfo dynamicInfo; memset(&dynamicInfo, 0, sizeof(dynamicInfo)); dynamicInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - dynamicInfo.dynamicStateCount = uint32_t(dynEnable.count()); + dynamicInfo.dynamicStateCount = uint32_t(dynEnable.size()); dynamicInfo.pDynamicStates = dynEnable.constData(); pipelineInfo.pDynamicState = &dynamicInfo; @@ -7101,7 +7101,7 @@ bool QVkGraphicsPipeline::create() | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; vktargetBlends.append(blend); } - blendInfo.attachmentCount = uint32_t(vktargetBlends.count()); + blendInfo.attachmentCount = uint32_t(vktargetBlends.size()); blendInfo.pAttachments = vktargetBlends.constData(); pipelineInfo.pColorBlendState = &blendInfo; diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 23e4f8f2be..7fc327c5c3 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -335,7 +335,7 @@ QByteArray QShader::serialized() const ds << QShaderPrivate::QSB_VERSION; ds << int(d->stage); d->desc.serialize(&ds); - ds << int(d->shaders.count()); + ds << int(d->shaders.size()); for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) { const QShaderKey &k(it.key()); writeShaderKey(&ds, k); @@ -343,24 +343,24 @@ QByteArray QShader::serialized() const ds << shader.shader(); ds << shader.entryPoint(); } - ds << int(d->bindings.count()); + ds << int(d->bindings.size()); for (auto it = d->bindings.cbegin(), itEnd = d->bindings.cend(); it != itEnd; ++it) { const QShaderKey &k(it.key()); writeShaderKey(&ds, k); const NativeResourceBindingMap &map(it.value()); - ds << int(map.count()); + ds << int(map.size()); for (auto mapIt = map.cbegin(), mapItEnd = map.cend(); mapIt != mapItEnd; ++mapIt) { ds << mapIt.key(); ds << mapIt.value().first; ds << mapIt.value().second; } } - ds << int(d->combinedImageMap.count()); + ds << int(d->combinedImageMap.size()); for (auto it = d->combinedImageMap.cbegin(), itEnd = d->combinedImageMap.cend(); it != itEnd; ++it) { const QShaderKey &k(it.key()); writeShaderKey(&ds, k); const SeparateToCombinedImageSamplerMappingList &list(it.value()); - ds << int(list.count()); + ds << int(list.size()); for (auto listIt = list.cbegin(), listItEnd = list.cend(); listIt != listItEnd; ++listIt) { ds << listIt->combinedSamplerName; ds << listIt->textureBinding; diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index d55caed210..ea1fbb9f89 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -829,7 +829,7 @@ static void serializeDecorations(QDataStream *stream, const QShaderDescription:: (*stream) << v.descriptorSet; (*stream) << int(v.imageFormat); (*stream) << int(v.imageFlags); - (*stream) << int(v.arrayDims.count()); + (*stream) << int(v.arrayDims.size()); for (int dim : v.arrayDims) (*stream) << dim; } @@ -884,13 +884,13 @@ static void serializeBlockMemberVar(QDataStream *stream, const QShaderDescriptio (*stream) << int(v.type); (*stream) << v.offset; (*stream) << v.size; - (*stream) << int(v.arrayDims.count()); + (*stream) << int(v.arrayDims.size()); for (int dim : v.arrayDims) (*stream) << dim; (*stream) << v.arrayStride; (*stream) << v.matrixStride; (*stream) << v.matrixIsRowMajor; - (*stream) << int(v.structMembers.count()); + (*stream) << int(v.structMembers.size()); for (const QShaderDescription::BlockVariable &sv : v.structMembers) serializeBlockMemberVar(stream, sv); } @@ -1017,55 +1017,55 @@ QJsonDocument QShaderDescriptionPrivate::makeDoc() void QShaderDescriptionPrivate::writeToStream(QDataStream *stream) { - (*stream) << int(inVars.count()); + (*stream) << int(inVars.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(inVars)) serializeInOutVar(stream, v); - (*stream) << int(outVars.count()); + (*stream) << int(outVars.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(outVars)) serializeInOutVar(stream, v); - (*stream) << int(uniformBlocks.count()); + (*stream) << int(uniformBlocks.size()); for (const QShaderDescription::UniformBlock &b : uniformBlocks) { (*stream) << QString::fromUtf8(b.blockName); (*stream) << QString::fromUtf8(b.structName); (*stream) << b.size; (*stream) << b.binding; (*stream) << b.descriptorSet; - (*stream) << int(b.members.count()); + (*stream) << int(b.members.size()); for (const QShaderDescription::BlockVariable &v : b.members) serializeBlockMemberVar(stream, v); } - (*stream) << int(pushConstantBlocks.count()); + (*stream) << int(pushConstantBlocks.size()); for (const QShaderDescription::PushConstantBlock &b : pushConstantBlocks) { (*stream) << QString::fromUtf8(b.name); (*stream) << b.size; - (*stream) << int(b.members.count()); + (*stream) << int(b.members.size()); for (const QShaderDescription::BlockVariable &v : b.members) serializeBlockMemberVar(stream, v); } - (*stream) << int(storageBlocks.count()); + (*stream) << int(storageBlocks.size()); for (const QShaderDescription::StorageBlock &b : storageBlocks) { (*stream) << QString::fromUtf8(b.blockName); (*stream) << QString::fromUtf8(b.instanceName); (*stream) << b.knownSize; (*stream) << b.binding; (*stream) << b.descriptorSet; - (*stream) << int(b.members.count()); + (*stream) << int(b.members.size()); for (const QShaderDescription::BlockVariable &v : b.members) serializeBlockMemberVar(stream, v); } - (*stream) << int(combinedImageSamplers.count()); + (*stream) << int(combinedImageSamplers.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(combinedImageSamplers)) { (*stream) << QString::fromUtf8(v.name); (*stream) << int(v.type); serializeDecorations(stream, v); } - (*stream) << int(storageImages.count()); + (*stream) << int(storageImages.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(storageImages)) { (*stream) << QString::fromUtf8(v.name); (*stream) << int(v.type); @@ -1075,14 +1075,14 @@ void QShaderDescriptionPrivate::writeToStream(QDataStream *stream) for (size_t i = 0; i < 3; ++i) (*stream) << localSize[i]; - (*stream) << int(separateImages.count()); + (*stream) << int(separateImages.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(separateImages)) { (*stream) << QString::fromUtf8(v.name); (*stream) << int(v.type); serializeDecorations(stream, v); } - (*stream) << int(separateSamplers.count()); + (*stream) << int(separateSamplers.size()); for (const QShaderDescription::InOutVariable &v : qAsConst(separateSamplers)) { (*stream) << QString::fromUtf8(v.name); (*stream) << int(v.type); diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 18f7b9b1ee..9c75031e32 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -602,7 +602,7 @@ QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const if (blockBr.contains(pos)) { QTextLayout *layout = block.layout(); int relativeCursorPos = cursorPos - block.position(); - const int preeditLength = layout ? layout->preeditAreaText().length() : 0; + const int preeditLength = layout ? layout->preeditAreaText().size() : 0; if (preeditLength > 0 && relativeCursorPos > layout->preeditAreaPosition()) cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength); break; diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index eff9ffbc8c..4b574161a7 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -408,7 +408,7 @@ int ValueExtractor::lengthValue(const Declaration &decl) { if (decl.d->parsed.isValid()) return lengthValueFromData(qvariant_cast<LengthData>(decl.d->parsed), f); - if (decl.d->values.count() < 1) + if (decl.d->values.size() < 1) return 0; LengthData data = lengthValue(decl.d->values.at(0)); decl.d->parsed = QVariant::fromValue<LengthData>(data); @@ -427,7 +427,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m) LengthData datas[4]; int i; - for (i = 0; i < qMin(decl.d->values.count(), 4); i++) + for (i = 0; i < qMin(decl.d->values.size(), 4); i++) datas[i] = lengthValue(decl.d->values[i]); if (i == 0) { @@ -455,7 +455,7 @@ bool ValueExtractor::extractGeometry(int *w, int *h, int *minw, int *minh, int * { extractFont(); bool hit = false; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case Width: *w = lengthValue(decl); break; @@ -477,7 +477,7 @@ bool ValueExtractor::extractPosition(int *left, int *top, int *right, int *botto { extractFont(); bool hit = false; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case Left: *left = lengthValue(decl); break; @@ -500,7 +500,7 @@ bool ValueExtractor::extractBox(int *margins, int *paddings, int *spacing) { extractFont(); bool hit = false; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case PaddingLeft: paddings[LeftEdge] = lengthValue(decl); break; @@ -527,7 +527,7 @@ bool ValueExtractor::extractBox(int *margins, int *paddings, int *spacing) int ValueExtractor::extractStyleFeatures() { int features = StyleFeature_None; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); if (decl.d->propertyId == QtStyleFeatures) features = decl.styleFeaturesValue(); @@ -544,9 +544,9 @@ QSize ValueExtractor::sizeValue(const Declaration &decl) } LengthData x[2] = { {0, LengthData::None }, {0, LengthData::None} }; - if (decl.d->values.count() > 0) + if (decl.d->values.size() > 0) x[0] = lengthValue(decl.d->values.at(0)); - if (decl.d->values.count() > 1) + if (decl.d->values.size() > 1) x[1] = lengthValue(decl.d->values.at(1)); else x[1] = x[0]; @@ -568,7 +568,7 @@ bool ValueExtractor::extractBorder(int *borders, QBrush *colors, BorderStyle *st { extractFont(); bool hit = false; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case BorderLeftWidth: borders[LeftEdge] = lengthValue(decl); break; @@ -627,7 +627,7 @@ bool ValueExtractor::extractOutline(int *borders, QBrush *colors, BorderStyle *s { extractFont(); bool hit = false; - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case OutlineWidth: lengthValues(decl, borders); break; @@ -696,7 +696,7 @@ static ColorData parseColorValue(QCss::Value v) return ColorData(); QStringList lst = v.variant.toStringList(); - if (lst.count() != 2) + if (lst.size() != 2) return ColorData(); const QString &identifier = lst.at(0); @@ -726,7 +726,7 @@ static ColorData parseColorValue(QCss::Value v) QList<QCss::Value> colorDigits; if (!p.parseExpr(&colorDigits)) return ColorData(); - const int tokenCount = colorDigits.count(); + const int tokenCount = colorDigits.size(); for (int i = 0; i < qMin(tokenCount, 7); i += 2) { if (colorDigits.at(i).type == Value::Percentage) { @@ -793,7 +793,7 @@ static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal) return BrushData(); QStringList lst = v.variant.toStringList(); - if (lst.count() != 2) + if (lst.size() != 2) return BrushData(); QStringList gradFuncs; @@ -959,7 +959,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord if (decl.d->values.at(i).type == Value::Length || decl.d->values.at(i).type == Value::Number) { data.width = lengthValue(decl.d->values.at(i)); *width = lengthValueFromData(data.width, f); - if (++i >= decl.d->values.count()) { + if (++i >= decl.d->values.size()) { decl.d->parsed = QVariant::fromValue<BorderData>(data); return; } @@ -968,7 +968,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord data.style = parseStyleValue(decl.d->values.at(i)); if (data.style != BorderStyle_Unknown) { *style = data.style; - if (++i >= decl.d->values.count()) { + if (++i >= decl.d->values.size()) { decl.d->parsed = QVariant::fromValue<BorderData>(data); return; } @@ -989,7 +989,7 @@ static void parseShorthandBackgroundProperty(const QList<QCss::Value> &values, B *repeat = Repeat_XY; *alignment = Qt::AlignTop | Qt::AlignLeft; - for (int i = 0; i < values.count(); ++i) { + for (int i = 0; i < values.size(); ++i) { const QCss::Value &v = values.at(i); if (v.type == Value::Uri) { *image = v.variant.toString(); @@ -1011,7 +1011,7 @@ static void parseShorthandBackgroundProperty(const QList<QCss::Value> &values, B if (v.type == Value::KnownIdentifier) { const int start = i; int count = 1; - if (i < values.count() - 1 + if (i < values.size() - 1 && values.at(i + 1).type == Value::KnownIdentifier) { ++i; ++count; @@ -1033,7 +1033,7 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re Origin *clip) { bool hit = false; - for (int i = 0; i < declarations.count(); ++i) { + for (int i = 0; i < declarations.size(); ++i) { const Declaration &decl = declarations.at(i); if (decl.d->values.isEmpty()) continue; @@ -1181,7 +1181,7 @@ static bool setFontFamilyFromValues(const QList<QCss::Value> &values, QFont *fon QString family; QStringList families; bool shouldAddSpace = false; - for (int i = start; i < values.count(); ++i) { + for (int i = start; i < values.size(); ++i) { const QCss::Value &v = values.at(i); if (v.type == Value::TermOperatorComma) { families << family; @@ -1207,7 +1207,7 @@ static bool setFontFamilyFromValues(const QList<QCss::Value> &values, QFont *fon static void setTextDecorationFromValues(const QList<QCss::Value> &values, QFont *font) { - for (int i = 0; i < values.count(); ++i) { + for (int i = 0; i < values.size(); ++i) { if (values.at(i).type != Value::KnownIdentifier) continue; switch (values.at(i).variant.toInt()) { @@ -1262,7 +1262,7 @@ static void parseShorthandFontProperty(const QList<QCss::Value> &values, QFont * *fontSizeAdjustment = -255; int i = 0; - while (i < values.count()) { + while (i < values.size()) { if (setFontStyleFromValue(values.at(i), font) || setFontWeightFromValue(values.at(i), font)) ++i; @@ -1270,12 +1270,12 @@ static void parseShorthandFontProperty(const QList<QCss::Value> &values, QFont * break; } - if (i < values.count()) { + if (i < values.size()) { setFontSizeFromValue(values.at(i), font, fontSizeAdjustment); ++i; } - if (i < values.count()) { + if (i < values.size()) { setFontFamilyFromValues(values, font, i); } } @@ -1312,7 +1312,7 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment) } bool hit = false; - for (int i = 0; i < declarations.count(); ++i) { + for (int i = 0; i < declarations.size(); ++i) { const Declaration &decl = declarations.at(i); if (decl.d->values.isEmpty()) continue; @@ -1343,7 +1343,7 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment) bool ValueExtractor::extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg) { bool hit = false; - for (int i = 0; i < declarations.count(); ++i) { + for (int i = 0; i < declarations.size(); ++i) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case Color: *fg = decl.brushValue(pal); break; @@ -1368,12 +1368,12 @@ void ValueExtractor::extractFont() bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size) { bool hit = false; - for (int i = 0; i < declarations.count(); ++i) { + for (int i = 0; i < declarations.size(); ++i) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { case QtImage: *icon = decl.iconValue(); - if (decl.d->values.count() > 0 && decl.d->values.at(0).type == Value::Uri) { + if (decl.d->values.size() > 0 && decl.d->values.at(0).type == Value::Uri) { // try to pull just the size from the image... QImageReader imageReader(decl.d->values.at(0).variant.toString()); if ((*size = imageReader.size()).isNull()) { @@ -1426,7 +1426,7 @@ bool ValueExtractor::extractIcon(QIcon *icon, QSize *size) // Declaration QColor Declaration::colorValue(const QPalette &pal) const { - if (d->values.count() != 1) + if (d->values.size() != 1) return QColor(); if (d->parsed.isValid()) { @@ -1456,7 +1456,7 @@ QColor Declaration::colorValue(const QPalette &pal) const QBrush Declaration::brushValue(const QPalette &pal) const { - if (d->values.count() != 1) + if (d->values.size() != 1) return QBrush(); if (d->parsed.isValid()) { @@ -1487,7 +1487,7 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const needParse = 0; Q_ASSERT(d->parsed.metaType() == QMetaType::fromType<QList<QVariant>>()); QList<QVariant> v = d->parsed.toList(); - for (i = 0; i < qMin(v.count(), 4); i++) { + for (i = 0; i < qMin(v.size(), 4); i++) { if (v.at(i).userType() == QMetaType::QBrush) { c[i] = qvariant_cast<QBrush>(v.at(i)); } else if (v.at(i).userType() == QMetaType::Int) { @@ -1499,7 +1499,7 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const } if (needParse != 0) { QList<QVariant> v; - for (i = 0; i < qMin(d->values.count(), 4); i++) { + for (i = 0; i < qMin(d->values.size(), 4); i++) { if (!(needParse & (1<<i))) continue; BrushData data = parseBrushValue(d->values.at(i), pal); @@ -1526,7 +1526,7 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const bool Declaration::realValue(qreal *real, const char *unit) const { - if (d->values.count() != 1) + if (d->values.size() != 1) return false; const Value &v = d->values.at(0); if (unit && v.type != Value::Length) @@ -1567,7 +1567,7 @@ static bool intValueHelper(const QCss::Value &v, int *i, const char *unit) bool Declaration::intValue(int *i, const char *unit) const { - if (d->values.count() != 1) + if (d->values.size() != 1) return false; return intValueHelper(d->values.at(0), i, unit); } @@ -1578,7 +1578,7 @@ QSize Declaration::sizeValue() const return qvariant_cast<QSize>(d->parsed); int x[2] = { 0, 0 }; - const int count = d->values.count(); + const int count = d->values.size(); for (int i = 0; i < count; ++i) { if (i > 1) { qWarning("QCssParser::sizeValue: Too many values provided"); @@ -1605,7 +1605,7 @@ QSize Declaration::sizeValue() const QRect Declaration::rectValue() const { - if (d->values.count() != 1) + if (d->values.size() != 1) return QRect(); if (d->parsed.isValid()) @@ -1615,10 +1615,10 @@ QRect Declaration::rectValue() const if (v.type != Value::Function) return QRect(); const QStringList func = v.variant.toStringList(); - if (func.count() != 2 || func.at(0).compare("rect"_L1) != 0) + if (func.size() != 2 || func.at(0).compare("rect"_L1) != 0) return QRect(); const auto args = QStringView{func[1]}.split(u' ', Qt::SkipEmptyParts); - if (args.count() != 4) + if (args.size() != 4) return QRect(); QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt()); d->parsed = QVariant::fromValue<QRect>(rect); @@ -1630,7 +1630,7 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const int i; if (d->parsed.isValid()) { QList<QVariant> v = d->parsed.toList(); - for (i = 0; i < qMin(d->values.count(), 4); i++) { + for (i = 0; i < qMin(d->values.size(), 4); i++) { if (v.at(i).userType() == QMetaType::QColor) { c[i] = qvariant_cast<QColor>(v.at(i)); } else { @@ -1639,7 +1639,7 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const } } else { QList<QVariant> v; - for (i = 0; i < qMin(d->values.count(), 4); i++) { + for (i = 0; i < qMin(d->values.size(), 4); i++) { ColorData color = parseColorValue(d->values.at(i)); if (color.type == ColorData::Role) { v += QVariant::fromValue<int>(color.role); @@ -1660,7 +1660,7 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const BorderStyle Declaration::styleValue() const { - if (d->values.count() != 1) + if (d->values.size() != 1) return BorderStyle_None; return parseStyleValue(d->values.at(0)); } @@ -1668,7 +1668,7 @@ BorderStyle Declaration::styleValue() const void Declaration::styleValues(BorderStyle *s) const { int i; - for (i = 0; i < qMin(d->values.count(), 4); i++) + for (i = 0; i < qMin(d->values.size(), 4); i++) s[i] = parseStyleValue(d->values.at(i)); if (i == 0) s[0] = s[1] = s[2] = s[3] = BorderStyle_None; else if (i == 1) s[3] = s[2] = s[1] = s[0]; @@ -1680,7 +1680,7 @@ Repeat Declaration::repeatValue() const { if (d->parsed.isValid()) return static_cast<Repeat>(d->parsed.toInt()); - if (d->values.count() != 1) + if (d->values.size() != 1) return Repeat_Unknown; int v = findKnownValue(d->values.at(0).variant.toString(), repeats, NumKnownRepeats); @@ -1692,7 +1692,7 @@ Origin Declaration::originValue() const { if (d->parsed.isValid()) return static_cast<Origin>(d->parsed.toInt()); - if (d->values.count() != 1) + if (d->values.size() != 1) return Origin_Unknown; int v = findKnownValue(d->values.at(0).variant.toString(), origins, NumKnownOrigins); @@ -1704,7 +1704,7 @@ PositionMode Declaration::positionValue() const { if (d->parsed.isValid()) return static_cast<PositionMode>(d->parsed.toInt()); - if (d->values.count() != 1) + if (d->values.size() != 1) return PositionMode_Unknown; int v = findKnownValue(d->values.at(0).variant.toString(), positions, NumKnownPositionModes); @@ -1716,7 +1716,7 @@ Attachment Declaration::attachmentValue() const { if (d->parsed.isValid()) return static_cast<Attachment>(d->parsed.toInt()); - if (d->values.count() != 1) + if (d->values.size() != 1) return Attachment_Unknown; int v = findKnownValue(d->values.at(0).variant.toString(), attachments, NumKnownAttachments); @@ -1730,7 +1730,7 @@ int Declaration::styleFeaturesValue() const if (d->parsed.isValid()) return d->parsed.toInt(); int features = StyleFeature_None; - for (int i = 0; i < d->values.count(); i++) { + for (int i = 0; i < d->values.size(); i++) { features |= static_cast<int>(findKnownValue(d->values.value(i).variant.toString(), styleFeatures, NumKnownStyleFeatures)); } @@ -1749,10 +1749,10 @@ Qt::Alignment Declaration::alignmentValue() const { if (d->parsed.isValid()) return Qt::Alignment(d->parsed.toInt()); - if (d->values.isEmpty() || d->values.count() > 2) + if (d->values.isEmpty() || d->values.size() > 2) return Qt::AlignLeft | Qt::AlignTop; - Qt::Alignment v = parseAlignment(d->values.constData(), d->values.count()); + Qt::Alignment v = parseAlignment(d->values.constData(), d->values.size()); d->parsed = int(v); return v; } @@ -1766,12 +1766,12 @@ void Declaration::borderImageValue(QString *image, int *cuts, cuts[i] = -1; *h = *v = TileMode_Stretch; - if (d->values.count() < 2) + if (d->values.size() < 2) return; if (d->values.at(1).type == Value::Number) { // cuts! int i; - for (i = 0; i < qMin(d->values.count()-1, 4); i++) { + for (i = 0; i < qMin(d->values.size()-1, 4); i++) { const Value& v = d->values.at(i+1); if (v.type != Value::Number) break; @@ -1787,9 +1787,9 @@ void Declaration::borderImageValue(QString *image, int *cuts, *v = static_cast<TileMode>(findKnownValue(d->values.last().variant.toString(), tileModes, NumKnownTileModes)); } - if (d->values[d->values.count() - 2].type == Value::Identifier) { + if (d->values[d->values.size() - 2].type == Value::Identifier) { *h = static_cast<TileMode> - (findKnownValue(d->values[d->values.count()-2].variant.toString(), + (findKnownValue(d->values[d->values.size()-2].variant.toString(), tileModes, NumKnownTileModes)); } else *h = *v; @@ -1797,7 +1797,7 @@ void Declaration::borderImageValue(QString *image, int *cuts, bool Declaration::borderCollapseValue() const { - if (d->values.count() != 1) + if (d->values.size() != 1) return false; else return d->values.at(0).toString() == "collapse"_L1; @@ -1809,7 +1809,7 @@ QIcon Declaration::iconValue() const return qvariant_cast<QIcon>(d->parsed); QIcon icon; - for (int i = 0; i < d->values.count();) { + for (int i = 0; i < d->values.size();) { const Value &value = d->values.at(i++); if (value.type != Value::Uri) break; @@ -1817,7 +1817,7 @@ QIcon Declaration::iconValue() const QIcon::Mode mode = QIcon::Normal; QIcon::State state = QIcon::Off; for (int j = 0; j < 2; j++) { - if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) { + if (i != d->values.size() && d->values.at(i).type == Value::KnownIdentifier) { switch (d->values.at(i).variant.toInt()) { case Value_Disabled: mode = QIcon::Disabled; break; case Value_Active: mode = QIcon::Active; break; @@ -1839,7 +1839,7 @@ QIcon Declaration::iconValue() const else icon.addPixmap(uri, mode, state); - if (i == d->values.count()) + if (i == d->values.size()) break; if (d->values.at(i).type == Value::TermOperatorComma) @@ -1855,13 +1855,13 @@ QIcon Declaration::iconValue() const int Selector::specificity() const { int val = 0; - for (int i = 0; i < basicSelectors.count(); ++i) { + for (int i = 0; i < basicSelectors.size(); ++i) { const BasicSelector &sel = basicSelectors.at(i); if (!sel.elementName.isEmpty()) val += 1; - val += (sel.pseudos.count() + sel.attributeSelectors.count()) * 0x10; - val += sel.ids.count() * 0x100; + val += (sel.pseudos.size() + sel.attributeSelectors.size()) * 0x10; + val += sel.ids.size() * 0x100; } return val; } @@ -1880,7 +1880,7 @@ quint64 Selector::pseudoClass(quint64 *negated) const if (bs.pseudos.isEmpty()) return PseudoClass_Unspecified; quint64 pc = PseudoClass_Unknown; - for (int i = !pseudoElement().isEmpty(); i < bs.pseudos.count(); i++) { + for (int i = !pseudoElement().isEmpty(); i < bs.pseudos.size(); i++) { const Pseudo &pseudo = bs.pseudos.at(i); if (pseudo.type == PseudoClass_Unknown) return PseudoClass_Unknown; @@ -1897,23 +1897,23 @@ quint64 Selector::pseudoClass(quint64 *negated) const void StyleSheet::buildIndexes(Qt::CaseSensitivity nameCaseSensitivity) { QList<StyleRule> universals; - for (int i = 0; i < styleRules.count(); ++i) { + for (int i = 0; i < styleRules.size(); ++i) { const StyleRule &rule = styleRules.at(i); QList<Selector> universalsSelectors; - for (int j = 0; j < rule.selectors.count(); ++j) { + for (int j = 0; j < rule.selectors.size(); ++j) { const Selector& selector = rule.selectors.at(j); if (selector.basicSelectors.isEmpty()) continue; if (selector.basicSelectors.at(0).relationToNext == BasicSelector::NoRelation) { - if (selector.basicSelectors.count() != 1) + if (selector.basicSelectors.size() != 1) continue; - } else if (selector.basicSelectors.count() <= 1) { + } else if (selector.basicSelectors.size() <= 1) { continue; } - const BasicSelector &sel = selector.basicSelectors.at(selector.basicSelectors.count() - 1); + const BasicSelector &sel = selector.basicSelectors.at(selector.basicSelectors.size() - 1); if (!sel.ids.isEmpty()) { StyleRule nr; @@ -1967,14 +1967,14 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) return false; if (selector.basicSelectors.at(0).relationToNext == BasicSelector::NoRelation) { - if (selector.basicSelectors.count() != 1) + if (selector.basicSelectors.size() != 1) return false; return basicSelectorMatches(selector.basicSelectors.at(0), node); } - if (selector.basicSelectors.count() <= 1) + if (selector.basicSelectors.size() <= 1) return false; - int i = selector.basicSelectors.count() - 1; + int i = selector.basicSelectors.size() - 1; node = duplicateNode(node); bool match = true; @@ -1982,7 +1982,7 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) do { match = basicSelectorMatches(sel, node); if (!match) { - if (i == selector.basicSelectors.count() - 1) // first element must always match! + if (i == selector.basicSelectors.size() - 1) // first element must always match! break; if (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor && sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent) @@ -2027,7 +2027,7 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) if (!hasAttributes(node)) return false; - for (int i = 0; i < sel.attributeSelectors.count(); ++i) { + for (int i = 0; i < sel.attributeSelectors.size(); ++i) { const QCss::AttributeSelector &a = sel.attributeSelectors.at(i); const QString attrValue = attributeValue(node, a); @@ -2090,14 +2090,14 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) void StyleSelector::matchRule(NodePtr node, const StyleRule &rule, StyleSheetOrigin origin, int depth, QMultiMap<uint, StyleRule> *weightedRules) { - for (int j = 0; j < rule.selectors.count(); ++j) { + for (int j = 0; j < rule.selectors.size(); ++j) { const Selector& selector = rule.selectors.at(j); if (selectorMatches(selector, node)) { uint weight = rule.order + selector.specificity() *0x100 + (uint(origin) + depth)*0x100000; StyleRule newRule = rule; - if (rule.selectors.count() > 1) { + if (rule.selectors.size() > 1) { newRule.selectors.resize(1); newRule.selectors[0] = selector; } @@ -2118,15 +2118,15 @@ QList<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) QMultiMap<uint, StyleRule> weightedRules; // (spec, rule) that will be sorted below //prune using indexed stylesheet - for (int sheetIdx = 0; sheetIdx < styleSheets.count(); ++sheetIdx) { + for (int sheetIdx = 0; sheetIdx < styleSheets.size(); ++sheetIdx) { const StyleSheet &styleSheet = styleSheets.at(sheetIdx); - for (int i = 0; i < styleSheet.styleRules.count(); ++i) { + for (int i = 0; i < styleSheet.styleRules.size(); ++i) { matchRule(node, styleSheet.styleRules.at(i), styleSheet.origin, styleSheet.depth, &weightedRules); } if (!styleSheet.idIndex.isEmpty()) { QStringList ids = nodeIds(node); - for (int i = 0; i < ids.count(); i++) { + for (int i = 0; i < ids.size(); i++) { const QString &key = ids.at(i); QMultiHash<QString, StyleRule>::const_iterator it = styleSheet.idIndex.constFind(key); while (it != styleSheet.idIndex.constEnd() && it.key() == key) { @@ -2137,7 +2137,7 @@ QList<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) } if (!styleSheet.nameIndex.isEmpty()) { QStringList names = nodeNames(node); - for (int i = 0; i < names.count(); i++) { + for (int i = 0; i < names.size(); i++) { QString name = names.at(i); if (nameCaseSensitivity == Qt::CaseInsensitive) name = std::move(name).toLower(); @@ -2149,9 +2149,9 @@ QList<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) } } if (!medium.isEmpty()) { - for (int i = 0; i < styleSheet.mediaRules.count(); ++i) { + for (int i = 0; i < styleSheet.mediaRules.size(); ++i) { if (styleSheet.mediaRules.at(i).media.contains(medium, Qt::CaseInsensitive)) { - for (int j = 0; j < styleSheet.mediaRules.at(i).styleRules.count(); ++j) { + for (int j = 0; j < styleSheet.mediaRules.at(i).styleRules.size(); ++j) { matchRule(node, styleSheet.mediaRules.at(i).styleRules.at(j), styleSheet.origin, styleSheet.depth, &weightedRules); } @@ -2160,7 +2160,7 @@ QList<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) } } - rules.reserve(weightedRules.count()); + rules.reserve(weightedRules.size()); QMultiMap<uint, StyleRule>::const_iterator it = weightedRules.constBegin(); for ( ; it != weightedRules.constEnd() ; ++it) rules += *it; @@ -2174,7 +2174,7 @@ QList<Declaration> StyleSelector::declarationsForNode(NodePtr node, const char * { QList<Declaration> decls; QList<StyleRule> rules = styleRulesForNode(node); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); const QString pseudoElement = selector.pseudoElement(); @@ -2888,7 +2888,7 @@ bool Parser::next(QCss::TokenType t) bool Parser::test(QCss::TokenType t) { - if (index >= symbols.count()) + if (index >= symbols.size()) return false; if (symbols.at(index).token == t) { ++index; diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index cc50fb76b1..493e680964 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -785,7 +785,7 @@ public: inline void skipSpace() { while (test(S)) {}; } - inline bool hasNext() const { return index < symbols.count(); } + inline bool hasNext() const { return index < symbols.size(); } inline TokenType next() { return symbols.at(index++).token; } bool next(TokenType t); bool test(TokenType t); @@ -796,7 +796,7 @@ public: QString lexemUntil(TokenType t); bool until(TokenType target, TokenType target2 = NONE); inline TokenType lookup() const { - return (index - 1) < symbols.count() ? symbols.at(index - 1).token : NONE; + return (index - 1) < symbols.size() ? symbols.at(index - 1).token : NONE; } bool testTokenAndEndsWith(TokenType t, QLatin1StringView str); diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp index 6b0d4c10ee..7bfa797782 100644 --- a/src/gui/text/qcssscanner.cpp +++ b/src/gui/text/qcssscanner.cpp @@ -8,7 +8,7 @@ public: QCssScanner_Generated(const QString &inp); inline QChar next() { - return (pos < input.length()) ? input.at(pos++) : QChar(); + return (pos < input.size()) ? input.at(pos++) : QChar(); } int handleCommentStart(); int lex(); diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 013f40fed6..adbde11237 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -530,14 +530,14 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path || (to.y() < offs << 8) || (to.y() >= (imgHeight - offs) << 8)); } - isConvex.resize(normals.count()); - for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) { + isConvex.resize(normals.size()); + for (int next = 0, prev = normals.size() - 1; next < normals.size(); prev = next++) { isConvex[prev] = normals.at(prev).x() * normals.at(next).y() - normals.at(prev).y() * normals.at(next).x() < 0; } // Draw quads. - for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) { + for (int next = 0, prev = normals.size() - 1; next < normals.size(); prev = next++) { QPoint n = normals.at(next); QPoint intPrev = vertices.at(prev); QPoint extPrev = vertices.at(prev); diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 316e92123e..36a2659071 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -179,7 +179,7 @@ static QStringList splitIntoFamilies(const QString &family) auto str = list.at(i).trimmed(); if ((str.startsWith(u'"') && str.endsWith(u'"')) || (str.startsWith(u'\'') && str.endsWith(u'\''))) { - str = str.mid(1, str.length() - 2); + str = str.mid(1, str.size() - 2); } familyList << str.toString(); } @@ -2125,7 +2125,7 @@ bool QFont::fromString(const QString &descrip) { const auto sr = QStringView(descrip).trimmed(); const auto l = sr.split(u','); - const int count = l.count(); + const int count = l.size(); if (!count || (count > 2 && count < 9) || count == 9 || count > 17 || l.first().isEmpty()) { qWarning("QFont::fromString: Invalid description '%s'", diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 5ffda4eb88..68041b8a2d 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -435,7 +435,7 @@ static void parseFontName(const QString &name, QString &foundry, QString &family // capitalize the family/foundry names bool space = true; QChar *s = family.data(); - int len = family.length(); + int len = family.size(); while(len--) { if (space) *s = s->toUpper(); space = s->isSpace(); @@ -444,7 +444,7 @@ static void parseFontName(const QString &name, QString &foundry, QString &family space = true; s = foundry.data(); - len = foundry.length(); + len = foundry.size(); while(len--) { if (space) *s = s->toUpper(); space = s->isSpace(); @@ -1320,7 +1320,7 @@ QFontDatabasePrivate *QFontDatabasePrivate::ensureFontDatabase() auto *platformFontDatabase = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); platformFontDatabase->populateFontDatabase(); - for (int i = 0; i < d->applicationFonts.count(); i++) { + for (int i = 0; i < d->applicationFonts.size(); i++) { auto *font = &d->applicationFonts[i]; if (!font->isNull() && !font->isPopulated()) platformFontDatabase->addApplicationFont(font->data, font->fileName, font); @@ -2147,12 +2147,12 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & Q_TRACE(QFontDatabasePrivate_addAppFont, fileName); int i; - for (i = 0; i < applicationFonts.count(); ++i) + for (i = 0; i < applicationFonts.size(); ++i) if (applicationFonts.at(i).isNull()) break; - if (i >= applicationFonts.count()) { + if (i >= applicationFonts.size()) { applicationFonts.append(ApplicationFont()); - i = applicationFonts.count() - 1; + i = applicationFonts.size() - 1; } if (font.fileName.isEmpty() && !fontData.isEmpty()) @@ -2176,7 +2176,7 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & bool QFontDatabasePrivate::isApplicationFont(const QString &fileName) { - for (int i = 0; i < applicationFonts.count(); ++i) + for (int i = 0; i < applicationFonts.size(); ++i) if (applicationFonts.at(i).fileName == fileName) return true; return false; @@ -2308,7 +2308,7 @@ bool QFontDatabase::removeApplicationFont(int handle) QMutexLocker locker(fontDatabaseMutex()); auto *db = QFontDatabasePrivate::instance(); - if (handle < 0 || handle >= db->applicationFonts.count()) + if (handle < 0 || handle >= db->applicationFonts.size()) return false; db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont(); diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 7997f643ab..4ab1435d2c 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -491,7 +491,7 @@ int QFontMetrics::horizontalAdvance(const QString &text, int len) const if (pos != -1) { len = (len < 0) ? pos : qMin(pos, len); } else if (len < 0) { - len = text.length(); + len = text.size(); } if (len == 0) return 0; @@ -517,7 +517,7 @@ int QFontMetrics::horizontalAdvance(const QString &text, const QTextOption &opti if (pos != -1) { len = (len < 0) ? pos : qMin(pos, len); } else if (len < 0) { - len = text.length(); + len = text.size(); } if (len == 0) return 0; @@ -604,12 +604,12 @@ int QFontMetrics::horizontalAdvance(QChar ch) const */ QRect QFontMetrics::boundingRect(const QString &text) const { - if (text.length() == 0) + if (text.size() == 0) return QRect(); QStackTextEngine layout(text, QFont(d.data())); layout.itemize(); - glyph_metrics_t gm = layout.boundingBox(0, text.length()); + glyph_metrics_t gm = layout.boundingBox(0, text.size()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); } @@ -639,13 +639,13 @@ QRect QFontMetrics::boundingRect(const QString &text) const */ QRect QFontMetrics::boundingRect(const QString &text, const QTextOption &option) const { - if (text.length() == 0) + if (text.size() == 0) return QRect(); QStackTextEngine layout(text, QFont(d.data())); layout.option = option; layout.itemize(); - glyph_metrics_t gm = layout.boundingBox(0, text.length()); + glyph_metrics_t gm = layout.boundingBox(0, text.size()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); } @@ -807,12 +807,12 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA */ QRect QFontMetrics::tightBoundingRect(const QString &text) const { - if (text.length() == 0) + if (text.size() == 0) return QRect(); QStackTextEngine layout(text, QFont(d.data())); layout.itemize(); - glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); + glyph_metrics_t gm = layout.tightBoundingBox(0, text.size()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); } @@ -839,13 +839,13 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const */ QRect QFontMetrics::tightBoundingRect(const QString &text, const QTextOption &option) const { - if (text.length() == 0) + if (text.size() == 0) return QRect(); QStackTextEngine layout(text, QFont(d.data())); layout.option = option; layout.itemize(); - glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); + glyph_metrics_t gm = layout.tightBoundingBox(0, text.size()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); } @@ -1402,7 +1402,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, int length) const if (pos != -1) length = (length < 0) ? pos : qMin(pos, length); else if (length < 0) - length = text.length(); + length = text.size(); if (length == 0) return 0; @@ -1429,7 +1429,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, const QTextOption &o if (pos != -1) length = (length < 0) ? pos : qMin(pos, length); else if (length < 0) - length = text.length(); + length = text.size(); if (length == 0) return 0; @@ -1516,7 +1516,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const */ QRectF QFontMetricsF::boundingRect(const QString &text) const { - int len = text.length(); + int len = text.size(); if (len == 0) return QRectF(); @@ -1551,13 +1551,13 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const */ QRectF QFontMetricsF::boundingRect(const QString &text, const QTextOption &option) const { - if (text.length() == 0) + if (text.size() == 0) return QRectF(); QStackTextEngine layout(text, QFont(d.data())); layout.option = option; layout.itemize(); - glyph_metrics_t gm = layout.boundingBox(0, text.length()); + glyph_metrics_t gm = layout.boundingBox(0, text.size()); return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); } @@ -1725,12 +1725,12 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta */ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const { - if (text.length() == 0) + if (text.size() == 0) return QRectF(); QStackTextEngine layout(text, QFont(d.data())); layout.itemize(); - glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); + glyph_metrics_t gm = layout.tightBoundingBox(0, text.size()); return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); } @@ -1757,13 +1757,13 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const */ QRectF QFontMetricsF::tightBoundingRect(const QString &text, const QTextOption &option) const { - if (text.length() == 0) + if (text.size() == 0) return QRectF(); QStackTextEngine layout(text, QFont(d.data())); layout.option = option; layout.itemize(); - glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); + glyph_metrics_t gm = layout.tightBoundingBox(0, text.size()); return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); } diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 7b97570781..1f5ffac8d4 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -608,7 +608,7 @@ static QTtfTable generateName(const QList<QTtfNameRecord> &name) const int name_size = 6 + 12*name.size(); int string_size = 0; for (int i = 0; i < name.size(); ++i) { - string_size += name.at(i).value.length()*char_size; + string_size += name.at(i).value.size()*char_size; } t.data.resize(name_size + string_size); @@ -624,7 +624,7 @@ static QTtfTable generateName(const QList<QTtfNameRecord> &name) int off = 0; for (int i = 0; i < name.size(); ++i) { - int len = name.at(i).value.length()*char_size; + int len = name.at(i).value.size()*char_size; // quint16 platformID Platform ID. // quint16 encodingID Platform-specific encoding ID. // quint16 languageID Language ID. diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp index 87d8c59128..4edd46ff0e 100644 --- a/src/gui/text/qinputcontrol.cpp +++ b/src/gui/text/qinputcontrol.cpp @@ -43,7 +43,7 @@ bool QInputControl::isAcceptableInput(const QKeyEvent *event) const if (c.category() == QChar::Other_PrivateUse) return true; - if (c.isHighSurrogate() && text.length() > 1 && text.at(1).isLowSurrogate()) + if (c.isHighSurrogate() && text.size() > 1 && text.at(1).isLowSurrogate()) return true; if (m_type == TextEdit && c == u'\t') diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index c377472439..b974a1d34d 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -66,7 +66,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() QList<QTextLayout::FormatRange> ranges = layout->formats(); const int preeditAreaStart = layout->preeditAreaPosition(); - const int preeditAreaLength = layout->preeditAreaText().length(); + const int preeditAreaLength = layout->preeditAreaText().size(); if (preeditAreaLength != 0) { auto isOutsidePreeditArea = [=](const QTextLayout::FormatRange &range) { @@ -81,22 +81,22 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } int i = 0; - while (i < formatChanges.count()) { + while (i < formatChanges.size()) { QTextLayout::FormatRange r; - while (i < formatChanges.count() && formatChanges.at(i) == r.format) + while (i < formatChanges.size() && formatChanges.at(i) == r.format) ++i; - if (i == formatChanges.count()) + if (i == formatChanges.size()) break; r.start = i; r.format = formatChanges.at(i); - while (i < formatChanges.count() && formatChanges.at(i) == r.format) + while (i < formatChanges.size() && formatChanges.at(i) == r.format) ++i; - Q_ASSERT(i <= formatChanges.count()); + Q_ASSERT(i <= formatChanges.size()); r.length = i - r.start; if (preeditAreaLength != 0) { @@ -403,10 +403,10 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block) void QSyntaxHighlighter::setFormat(int start, int count, const QTextCharFormat &format) { Q_D(QSyntaxHighlighter); - if (start < 0 || start >= d->formatChanges.count()) + if (start < 0 || start >= d->formatChanges.size()) return; - const int end = qMin(start + count, d->formatChanges.count()); + const int end = qMin(start + count, d->formatChanges.size()); for (int i = start; i < end; ++i) d->formatChanges[i] = format; } @@ -456,7 +456,7 @@ void QSyntaxHighlighter::setFormat(int start, int count, const QFont &font) QTextCharFormat QSyntaxHighlighter::format(int pos) const { Q_D(const QSyntaxHighlighter); - if (pos < 0 || pos >= d->formatChanges.count()) + if (pos < 0 || pos >= d->formatChanges.size()) return QTextCharFormat(); return d->formatChanges.at(pos); } diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 884a16ca78..c23bcf0317 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1423,18 +1423,18 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format QTextBlockFormat blockFmt = blockFormat(); - int textStart = d->priv->text.length(); + int textStart = d->priv->text.size(); int blockStart = 0; d->priv->text += text; - int textEnd = d->priv->text.length(); + int textEnd = d->priv->text.size(); - for (int i = 0; i < text.length(); ++i) { + for (int i = 0; i < text.size(); ++i) { QChar ch = text.at(i); const int blockEnd = i; if (ch == u'\r' - && (i + 1) < text.length() + && (i + 1) < text.size() && text.at(i + 1) == u'\n') { ++i; ch = text.at(i); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index c692ab0574..a6675422cd 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -67,14 +67,14 @@ bool Qt::mightBeRichText(const QString& text) return false; int start = 0; - while (start < text.length() && text.at(start).isSpace()) + while (start < text.size() && text.at(start).isSpace()) ++start; // skip a leading <?xml ... ?> as for example with xhtml if (QStringView{text}.mid(start, 5).compare("<?xml"_L1) == 0) { - while (start < text.length()) { + while (start < text.size()) { if (text.at(start) == u'?' - && start + 2 < text.length() + && start + 2 < text.size() && text.at(start + 1) == u'>') { start += 2; break; @@ -82,20 +82,20 @@ bool Qt::mightBeRichText(const QString& text) ++start; } - while (start < text.length() && text.at(start).isSpace()) + while (start < text.size() && text.at(start).isSpace()) ++start; } if (QStringView{text}.mid(start, 5).compare("<!doc"_L1, Qt::CaseInsensitive) == 0) return true; int open = start; - while (open < text.length() && text.at(open) != u'<' + while (open < text.size() && text.at(open) != u'<' && text.at(open) != u'\n') { if (text.at(open) == u'&' && QStringView{text}.mid(open + 1, 3) == "lt;"_L1) return true; // support desperate attempt of user to see <...> ++open; } - if (open < text.length() && text.at(open) == u'<') { + if (open < text.size() && text.at(open) == u'<') { const int close = text.indexOf(u'>', open); if (close > -1) { QString tag; @@ -134,10 +134,10 @@ QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode) int col = 0; QString rich; rich += "<p>"_L1; - for (int i = 0; i < plain.length(); ++i) { + for (int i = 0; i < plain.size(); ++i) { if (plain[i] == u'\n'){ int c = 1; - while (i+1 < plain.length() && plain[i+1] == u'\n') { + while (i+1 < plain.size() && plain[i+1] == u'\n') { i++; c++; } @@ -1310,7 +1310,7 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively ? Qt::CaseSensitive : Qt::CaseInsensitive; int idx = -1; - while (offset >= 0 && offset <= text.length()) { + while (offset >= 0 && offset <= text.size()) { idx = (options & QTextDocument::FindBackward) ? text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity); if (idx == -1) @@ -1318,9 +1318,9 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int if (options & QTextDocument::FindWholeWords) { const int start = idx; - const int end = start + expression.length(); + const int end = start + expression.size(); if ((start != 0 && text.at(start - 1).isLetterOrNumber()) - || (end != text.length() && text.at(end).isLetterOrNumber())) { + || (end != text.size() && text.at(end).isLetterOrNumber())) { //if this is not a whole word, continue the search in the string offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1; idx = -1; @@ -1330,7 +1330,7 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int //we have a hit, return the cursor for that. *cursor = QTextCursorPrivate::fromPosition(const_cast<QTextDocumentPrivate *>(QTextDocumentPrivate::get(block)), block.position() + idx); - cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor); + cursor->setPosition(cursor->position() + expression.size(), QTextCursor::KeepAnchor); return true; } return false; @@ -1430,7 +1430,7 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expr, QRegularExpressionMatch match; int idx = -1; - while (offset >= 0 && offset <= text.length()) { + while (offset >= 0 && offset <= text.size()) { idx = (options & QTextDocument::FindBackward) ? text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match); if (idx == -1) @@ -1440,7 +1440,7 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expr, const int start = idx; const int end = start + match.capturedLength(); if ((start != 0 && text.at(start - 1).isLetterOrNumber()) - || (end != text.length() && text.at(end).isLetterOrNumber())) { + || (end != text.size() && text.at(end).isLetterOrNumber())) { //if this is not a whole word, continue the search in the string offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1; idx = -1; @@ -2324,7 +2324,7 @@ static QString colorValue(QColor color) result = color.name(); } else if (color.alpha()) { QString alphaValue = QString::number(color.alphaF(), 'f', 6); - while (alphaValue.length() > 1 && alphaValue.at(alphaValue.size() - 1) == u'0') + while (alphaValue.size() > 1 && alphaValue.at(alphaValue.size() - 1) == u'0') alphaValue.chop(1); if (alphaValue.at(alphaValue.size() - 1) == u'.') alphaValue.chop(1); @@ -2830,7 +2830,7 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) html.chop(styleTag.size()); if (isObject) { - for (int i = 0; isImage && i < txt.length(); ++i) { + for (int i = 0; isImage && i < txt.size(); ++i) { QTextImageFormat imgFmt = format.toImageFormat(); html += "<img"_L1; @@ -3260,7 +3260,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table) columnWidths.resize(columns); columnWidths.fill(QTextLength()); } - Q_ASSERT(columnWidths.count() == columns); + Q_ASSERT(columnWidths.size() == columns); QVarLengthArray<bool> widthEmittedForColumn(columns); for (int i = 0; i < columns; ++i) @@ -3437,7 +3437,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType { const auto styleAttribute = " style=\""_L1; html += styleAttribute; - const int originalHtmlLength = html.length(); + const int originalHtmlLength = html.size(); if (frameType == TextFrame) html += "-qt-table-type: frame;"_L1; @@ -3471,7 +3471,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType if (format.property(QTextFormat::TableBorderCollapse).toBool()) html += " border-collapse:collapse;"_L1; - if (html.length() == originalHtmlLength) // nothing emitted? + if (html.size() == originalHtmlLength) // nothing emitted? html.chop(styleAttribute.size()); else html += u'\"'; diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index e61194ab1e..0b9be23271 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -373,7 +373,7 @@ int QTextDocumentPrivate::insertBlock(QChar blockSeparator, beginEditBlock(); - int strPos = text.length(); + int strPos = text.size(); text.append(blockSeparator); int ob = blocks.findNode(pos); @@ -450,9 +450,9 @@ void QTextDocumentPrivate::insert(int pos, const QString &str, int format) Q_ASSERT(noBlockInString(str)); - int strPos = text.length(); + int strPos = text.size(); text.append(str); - insert(pos, strPos, str.length(), format); + insert(pos, strPos, str.size(), format); } int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::Operation op) @@ -1433,7 +1433,7 @@ QTextFrame *QTextDocumentPrivate::frameAt(int pos) const void QTextDocumentPrivate::clearFrame(QTextFrame *f) { - for (int i = 0; i < f->d_func()->childFrames.count(); ++i) + for (int i = 0; i < f->d_func()->childFrames.size(); ++i) clearFrame(f->d_func()->childFrames.at(i)); f->d_func()->childFrames.clear(); f->d_func()->parentFrame = nullptr; diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 0118c34c97..e96f7cf995 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -84,7 +84,7 @@ int QTextCopyHelper::appendFragment(int pos, int endPos, int objectIndex) } QString txtToInsert(originalText.constData() + frag->stringPosition + inFragmentOffset, charsToCopy); - if (txtToInsert.length() == 1 + if (txtToInsert.size() == 1 && (txtToInsert.at(0) == QChar::ParagraphSeparator || txtToInsert.at(0) == QTextBeginningOfFrame || txtToInsert.at(0) == QTextEndOfFrame @@ -109,7 +109,7 @@ int QTextCopyHelper::appendFragment(int pos, int endPos, int objectIndex) const int userState = nextBlock.userState(); if (userState != -1) dst->blocksFind(insertPos).setUserState(userState); - insertPos += txtToInsert.length(); + insertPos += txtToInsert.size(); } return charsToCopy; @@ -580,7 +580,7 @@ bool QTextHtmlImporter::appendNodeText() QString textToInsert; textToInsert.reserve(text.size()); - for (int i = 0; i < text.length(); ++i) { + for (int i = 0; i < text.size(); ++i) { QChar ch = text.at(i); if (ch.isSpace() @@ -621,7 +621,7 @@ bool QTextHtmlImporter::appendNodeText() || ch == QChar::ParagraphSeparator) { if (!textToInsert.isEmpty()) { - if (wsm == QTextHtmlParserNode::WhiteSpacePreLine && textToInsert.at(textToInsert.length() - 1) == u' ') + if (wsm == QTextHtmlParserNode::WhiteSpacePreLine && textToInsert.at(textToInsert.size() - 1) == u' ') textToInsert = textToInsert.chopped(1); cursor.insertText(textToInsert, format); textToInsert.clear(); @@ -906,7 +906,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) int tableHeaderRowCount = 0; QList<int> rowNodes; - rowNodes.reserve(at(tableNodeIdx).children.count()); + rowNodes.reserve(at(tableNodeIdx).children.size()); for (int row : at(tableNodeIdx).children) { switch (at(row).id) { case Html_tr: @@ -959,7 +959,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) if (spanInfo.colSpan > 1 || spanInfo.rowSpan > 1) rowColSpans.append(spanInfo); - columnWidths.resize(qMax(columnWidths.count(), colsInRow)); + columnWidths.resize(qMax(columnWidths.size(), colsInRow)); rowColSpanForColumn.resize(columnWidths.size()); for (int i = currentColumn; i < currentColumn + c.tableCellColSpan; ++i) { if (columnWidths.at(i).type() == QTextLength::VariableLength) { @@ -1041,7 +1041,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) QTextTable *textTable = cursor.insertTable(table.rows, table.columns, fmt.toTableFormat()); table.frame = textTable; - for (int i = 0; i < rowColSpans.count(); ++i) { + for (int i = 0; i < rowColSpans.size(); ++i) { const RowColSpanInfo &nfo = rowColSpans.at(i); textTable->mergeCells(nfo.row, nfo.col, nfo.rowSpan, nfo.colSpan); } diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 714632ba58..c95ec4c686 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -1175,7 +1175,7 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain it = frameIteratorForYPosition(QFixed::fromReal(context.clip.top())); QList<QTextFrame *> floats; - const int numFloats = fd->floats.count(); + const int numFloats = fd->floats.size(); floats.reserve(numFloats); for (int i = 0; i < numFloats; ++i) floats.append(fd->floats.at(i)); @@ -1967,7 +1967,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint previousFrame = c; } - for (int i = 0; i < floats.count(); ++i) { + for (int i = 0; i < floats.size(); ++i) { QTextFrame *frame = floats.at(i); if (!isFrameFromInlineObject(frame) || frame->frameFormat().position() == QTextFrameFormat::InFlow) @@ -2368,7 +2368,7 @@ QRectF QTextDocumentLayoutPrivate::layoutTable(QTextTable *table, int layoutFrom td->childFrameMap.clear(); { const QList<QTextFrame *> children = table->childFrames(); - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QTextFrame *frame = children.at(i); QTextTableCell cell = table->cellAt(frame->firstPosition()); td->childFrameMap.insert(cell.row() + cell.column() * rows, frame); @@ -2378,7 +2378,7 @@ QRectF QTextDocumentLayoutPrivate::layoutTable(QTextTable *table, int layoutFrom QList<QTextLength> columnWidthConstraints = fmt.columnWidthConstraints(); if (columnWidthConstraints.size() != columns) columnWidthConstraints.resize(columns); - Q_ASSERT(columnWidthConstraints.count() == columns); + Q_ASSERT(columnWidthConstraints.size() == columns); // borderCollapse will disable drawing the html4 style table cell borders // and draw a 1px grid instead. This also sets a fixed cellspacing @@ -2575,9 +2575,9 @@ recalc_minmax_widths: QFixed lastRemainingWidth = remainingWidth; while (remainingWidth > 0) { - for (int k = 0; k < columnsWithProperMaxSize.count(); ++k) { + for (int k = 0; k < columnsWithProperMaxSize.size(); ++k) { const int col = columnsWithProperMaxSize[k]; - const int colsLeft = columnsWithProperMaxSize.count() - k; + const int colsLeft = columnsWithProperMaxSize.size() - k; const QFixed w = qMin(td->maxWidths.at(col) - td->widths.at(col), remainingWidth / colsLeft); td->widths[col] += w; remainingWidth -= w; @@ -3349,7 +3349,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout // and not per cell and layoutCell already takes care of doing the same as we do here if (!qobject_cast<QTextTable *>(layoutStruct->frame)) { QList<QTextFrame *> children = layoutStruct->frame->childFrames(); - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QTextFrameData *fd = data(children.at(i)); if (!fd->layoutDirty && children.at(i)->frameFormat().position() != QTextFrameFormat::InFlow) layoutStruct->y = qMax(layoutStruct->y, fd->position.y + fd->size.height); @@ -3850,7 +3850,7 @@ int QTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accur // ensure we stay within document bounds int lastPos = f->lastPosition(); if (l && !l->preeditAreaText().isEmpty()) - lastPos += l->preeditAreaText().length(); + lastPos += l->preeditAreaText().size(); if (position > lastPos) position = lastPos; else if (position < 0) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index c6da4b8f4a..e473c26a2c 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -101,7 +101,7 @@ private: if (!m_splitter) m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, - m_string.constData(), m_string.length(), + m_string.constData(), m_string.size(), /*buffer*/nullptr, /*buffer size*/0); m_splitter->setPosition(start); @@ -1781,7 +1781,7 @@ const QCharAttributes *QTextEngine::attributes() const return (QCharAttributes *) layoutData->memory; itemize(); - if (! ensureSpace(layoutData->string.length())) + if (! ensureSpace(layoutData->string.size())) return nullptr; QVarLengthArray<QUnicodeTools::ScriptItem> scriptItems(layoutData->items.size()); @@ -1888,7 +1888,7 @@ void QTextEngine::itemize() const if (layoutData->items.size()) return; - int length = layoutData->string.length(); + int length = layoutData->string.size(); if (!length) return; @@ -1905,9 +1905,9 @@ void QTextEngine::itemize() const { QUnicodeTools::ScriptItemArray scriptItems; QUnicodeTools::initScripts(layoutData->string, &scriptItems); - for (int i = 0; i < scriptItems.length(); ++i) { + for (int i = 0; i < scriptItems.size(); ++i) { const auto &item = scriptItems.at(i); - int end = i < scriptItems.length() - 1 ? scriptItems.at(i + 1).position : length; + int end = i < scriptItems.size() - 1 ? scriptItems.at(i + 1).position : length; for (int j = item.position; j < end; ++j) analysis[j].script = item.script; } @@ -1970,7 +1970,7 @@ void QTextEngine::itemize() const const QTextFragmentData * const frag = it.value(); if (it == end || format != frag->format) { if (s && position >= preeditPosition) { - position += s->preeditText.length(); + position += s->preeditText.size(); preeditPosition = INT_MAX; } Q_ASSERT(position <= length); @@ -2399,7 +2399,7 @@ void QTextEngine::justify(const QScriptLine &line) if (!forceJustification) { int end = line.from + (int)line.length + line.trailingSpaces; - if (end == layoutData->string.length()) + if (end == layoutData->string.size()) return; // no justification at end of paragraph if (end && layoutData->items.at(findItem(end - 1)).analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) return; // no justification at the end of an explicitly separated line @@ -2612,11 +2612,11 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int { allocated = _allocated; - int space_charAttributes = int(sizeof(QCharAttributes) * string.length() / sizeof(void*) + 1); - int space_logClusters = int(sizeof(unsigned short) * string.length() / sizeof(void*) + 1); + int space_charAttributes = int(sizeof(QCharAttributes) * string.size() / sizeof(void*) + 1); + int space_logClusters = int(sizeof(unsigned short) * string.size() / sizeof(void*) + 1); available_glyphs = ((int)allocated - space_charAttributes - space_logClusters)*(int)sizeof(void*)/(int)QGlyphLayout::SpaceNeeded; - if (available_glyphs < str.length()) { + if (available_glyphs < str.size()) { // need to allocate on the heap allocated = 0; @@ -2629,7 +2629,7 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int logClustersPtr = (unsigned short *)(memory + space_charAttributes); void *m = memory + space_charAttributes + space_logClusters; - glyphLayout = QGlyphLayout(reinterpret_cast<char *>(m), str.length()); + glyphLayout = QGlyphLayout(reinterpret_cast<char *>(m), str.size()); glyphLayout.clear(); memset(memory, 0, space_charAttributes*sizeof(void *)); } @@ -2654,8 +2654,8 @@ bool QTextEngine::LayoutData::reallocate(int totalGlyphs) return true; } - int space_charAttributes = int(sizeof(QCharAttributes) * string.length() / sizeof(void*) + 1); - int space_logClusters = int(sizeof(unsigned short) * string.length() / sizeof(void*) + 1); + int space_charAttributes = int(sizeof(QCharAttributes) * string.size() / sizeof(void*) + 1); + int space_logClusters = int(sizeof(unsigned short) * string.size() / sizeof(void*) + 1); int space_glyphs = (totalGlyphs * QGlyphLayout::SpaceNeeded) / sizeof(void *) + 2; int newAllocated = space_charAttributes + space_glyphs + space_logClusters; @@ -2745,10 +2745,10 @@ int QTextEngine::formatIndex(const QScriptItem *si) const return -1; int pos = si->position; if (specialData && si->position >= specialData->preeditPosition) { - if (si->position < specialData->preeditPosition + specialData->preeditText.length()) + if (si->position < specialData->preeditPosition + specialData->preeditText.size()) pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0); else - pos -= specialData->preeditText.length(); + pos -= specialData->preeditText.size(); } QTextDocumentPrivate::FragmentIterator it = p->find(block.position() + pos); return it.value()->format; @@ -2883,9 +2883,9 @@ void QTextEngine::indexFormats() */ static inline bool nextCharJoins(const QString &string, int pos) { - while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing) + while (pos < string.size() && string.at(pos).category() == QChar::Mark_NonSpacing) ++pos; - if (pos == string.length()) + if (pos == string.size()) return false; QChar::JoiningType joining = string.at(pos).joiningType(); return joining != QChar::Joining_None && joining != QChar::Joining_Transparent; @@ -2968,12 +2968,12 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, QFixed width, int flags, validate(); - const int to = count >= 0 && count <= layoutData->string.length() - from + const int to = count >= 0 && count <= layoutData->string.size() - from ? from + count - : layoutData->string.length(); + : layoutData->string.size(); if (mode == Qt::ElideNone - || this->width(from, layoutData->string.length()) <= width + || this->width(from, layoutData->string.size()) <= width || to - from <= 1) return layoutData->string.mid(from, from - to); @@ -3040,7 +3040,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, QFixed width, int flags, pos = nextBreak; ++nextBreak; - while (nextBreak < layoutData->string.length() && !attributes[nextBreak].graphemeBoundary) + while (nextBreak < layoutData->string.size() && !attributes[nextBreak].graphemeBoundary) ++nextBreak; currentWidth += this->width(pos, nextBreak - pos); @@ -3092,7 +3092,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, QFixed width, int flags, rightPos = nextRightBreak; ++nextLeftBreak; - while (nextLeftBreak < layoutData->string.length() && !attributes[nextLeftBreak].graphemeBoundary) + while (nextLeftBreak < layoutData->string.size() && !attributes[nextLeftBreak].graphemeBoundary) ++nextLeftBreak; --nextRightBreak; @@ -3168,11 +3168,11 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const for (const QTextOption::Tab &tabSpec : qAsConst(tabArray)) { QFixed tab = QFixed::fromReal(tabSpec.position) * dpiScale; if (tab > x) { // this is the tab we need. - int tabSectionEnd = layoutData->string.length(); + int tabSectionEnd = layoutData->string.size(); if (tabSpec.type == QTextOption::RightTab || tabSpec.type == QTextOption::CenterTab) { // find next tab to calculate the width required. tab = QFixed::fromReal(tabSpec.position); - for (int i=item + 1; i < layoutData->items.count(); i++) { + for (int i=item + 1; i < layoutData->items.size(); i++) { const QScriptItem &item = layoutData->items[i]; if (item.analysis.flags == QScriptAnalysis::TabOrObject) { // found it. tabSectionEnd = item.position; @@ -3187,7 +3187,7 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const if (tabSectionEnd > si.position) { QFixed length; // Calculate the length of text between this tab and the tabSectionEnd - for (int i=item; i < layoutData->items.count(); i++) { + for (int i=item; i < layoutData->items.size(); i++) { const QScriptItem &item = layoutData->items.at(i); if (item.position > tabSectionEnd || item.position <= si.position) continue; @@ -3259,7 +3259,7 @@ void QTextEngine::resolveFormats() const QTextFormatCollection *collection = formatCollection(); - QList<QTextCharFormat> resolvedFormats(layoutData->items.count()); + QList<QTextCharFormat> resolvedFormats(layoutData->items.size()); QVarLengthArray<int, 64> formatsSortedByStart; formatsSortedByStart.reserve(specialData->formats.size()); @@ -3277,7 +3277,7 @@ void QTextEngine::resolveFormats() const const int *startIt = formatsSortedByStart.constBegin(); const int *endIt = formatsSortedByEnd.constBegin(); - for (int i = 0; i < layoutData->items.count(); ++i) { + for (int i = 0; i < layoutData->items.size(); ++i) { const QScriptItem *si = &layoutData->items.at(i); int end = si->position + length(si); @@ -3453,8 +3453,8 @@ int QTextEngine::previousLogicalPosition(int oldPos) const { const QCharAttributes *attrs = attributes(); int len = block.isValid() ? block.length() - 1 - : layoutData->string.length(); - Q_ASSERT(len <= layoutData->string.length()); + : layoutData->string.size(); + Q_ASSERT(len <= layoutData->string.size()); if (!attrs || oldPos <= 0 || oldPos > len) return oldPos; @@ -3468,8 +3468,8 @@ int QTextEngine::nextLogicalPosition(int oldPos) const { const QCharAttributes *attrs = attributes(); int len = block.isValid() ? block.length() - 1 - : layoutData->string.length(); - Q_ASSERT(len <= layoutData->string.length()); + : layoutData->string.size(); + Q_ASSERT(len <= layoutData->string.size()); if (!attrs || oldPos < 0 || oldPos >= len) return oldPos; @@ -3483,7 +3483,7 @@ int QTextEngine::lineNumberForTextPosition(int pos) { if (!layoutData) itemize(); - if (pos == layoutData->string.length() && lines.size()) + if (pos == layoutData->string.size() && lines.size()) return lines.size() - 1; for (int i = 0; i < lines.size(); ++i) { const QScriptLine& line = lines[i]; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index c653bfc92f..925dafe04e 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -434,14 +434,14 @@ public: const QScriptItem &si = layoutData->items[item]; int from = si.position; item++; - return (item < layoutData->items.size() ? layoutData->items[item].position : layoutData->string.length()) - from; + return (item < layoutData->items.size() ? layoutData->items[item].position : layoutData->string.size()) - from; } int length(const QScriptItem *si) const { int end; if (si + 1 < layoutData->items.constData()+ layoutData->items.size()) end = (si+1)->position; else - end = layoutData->string.length(); + end = layoutData->string.size(); return end - si->position; } diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index be38aba368..508d472062 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -168,7 +168,7 @@ public: if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty) fontDirty = true; - for (int i = 0; i < props.count(); ++i) + for (int i = 0; i < props.size(); ++i) if (props.at(i).key == key) { props[i].value = value; return; @@ -178,7 +178,7 @@ public: inline void clearProperty(qint32 key) { - for (int i = 0; i < props.count(); ++i) + for (int i = 0; i < props.size(); ++i) if (props.at(i).key == key) { hashDirty = true; if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty) @@ -190,7 +190,7 @@ public: inline int propertyIndex(qint32 key) const { - for (int i = 0; i < props.count(); ++i) + for (int i = 0; i < props.size(); ++i) if (props.at(i).key == key) return i; return -1; @@ -257,7 +257,7 @@ static inline size_t variantHash(const QVariant &variant) case QMetaType::Bool: return 0x371818 + variant.toBool(); case QMetaType::QPen: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); case QMetaType::QVariantList: - return 0x8377U + qvariant_cast<QVariantList>(variant).count(); + return 0x8377U + qvariant_cast<QVariantList>(variant).size(); case QMetaType::QColor: return hash(qvariant_cast<QColor>(variant)); case QMetaType::QTextLength: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); @@ -318,7 +318,7 @@ void QTextFormatPrivate::recalcFont() const QFont::SpacingType spacingType = QFont::PercentageSpacing; qreal letterSpacing = 0.0; - for (int i = 0; i < props.count(); ++i) { + for (int i = 0; i < props.size(); ++i) { switch (props.at(i).key) { case QTextFormat::FontFamilies: f.setFamilies(props.at(i).value.toStringList()); @@ -951,7 +951,7 @@ void QTextFormat::merge(const QTextFormat &other) const QList<QT_PREPEND_NAMESPACE(Property)> &otherProps = other.d.constData()->props; p->props.reserve(p->props.size() + otherProps.size()); - for (int i = 0; i < otherProps.count(); ++i) { + for (int i = 0; i < otherProps.size(); ++i) { const QT_PREPEND_NAMESPACE(Property) &prop = otherProps.at(i); p->insertProperty(prop.key, prop.value); } @@ -1323,7 +1323,7 @@ QMap<int, QVariant> QTextFormat::properties() const { QMap<int, QVariant> map; if (d) { - for (int i = 0; i < d->props.count(); ++i) + for (int i = 0; i < d->props.size(); ++i) map.insert(d->props.at(i).key, d->props.at(i).value); } return map; @@ -1335,7 +1335,7 @@ QMap<int, QVariant> QTextFormat::properties() const */ int QTextFormat::propertyCount() const { - return d ? d->props.count() : 0; + return d ? d->props.size() : 0; } /*! @@ -2237,7 +2237,7 @@ QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt) void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs) { QList<QVariant> list; - list.reserve(tabs.count()); + list.reserve(tabs.size()); QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin(); while (iter != tabs.constEnd()) { QVariant v; @@ -2262,7 +2262,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const QList<QTextOption::Tab> answer; QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant); QList<QVariant>::Iterator iter = variantsList.begin(); - answer.reserve(variantsList.count()); + answer.reserve(variantsList.size()); while(iter != variantsList.end()) { answer.append( qvariant_cast<QTextOption::Tab>(*iter)); ++iter; @@ -3988,7 +3988,7 @@ int QTextFormatCollection::createObjectIndex(const QTextFormat &f) QTextFormat QTextFormatCollection::format(int idx) const { - if (idx < 0 || idx >= formats.count()) + if (idx < 0 || idx >= formats.size()) return QTextFormat(); return formats.at(idx); @@ -3997,7 +3997,7 @@ QTextFormat QTextFormatCollection::format(int idx) const void QTextFormatCollection::setDefaultFont(const QFont &f) { defaultFnt = f; - for (int i = 0; i < formats.count(); ++i) + for (int i = 0; i < formats.size(); ++i) if (formats.at(i).d) formats[i].d->resolveFont(defaultFnt); } diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index fac7082c1d..1bd9120513 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -55,7 +55,7 @@ public: inline QTextImageFormat imageFormat(int index) const { return format(index).toImageFormat(); } - inline int numFormats() const { return formats.count(); } + inline int numFormats() const { return formats.size(); } typedef QList<QTextFormat> FormatVector; diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index ded2dd185a..55c64bb256 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -488,7 +488,7 @@ QTextHtmlParserNode *QTextHtmlParser::newNode(int parent) bool reuseLastNode = true; - if (nodes.count() == 1) { + if (nodes.size() == 1) { reuseLastNode = false; } else if (lastNode->tag.isEmpty()) { @@ -496,7 +496,7 @@ QTextHtmlParserNode *QTextHtmlParser::newNode(int parent) reuseLastNode = true; } else { // last node is a text node (empty tag) with some text - if (lastNode->text.length() == 1 && lastNode->text.at(0).isSpace()) { + if (lastNode->text.size() == 1 && lastNode->text.at(0).isSpace()) { int lastSibling = count() - 2; while (lastSibling @@ -543,7 +543,7 @@ void QTextHtmlParser::parse(const QString &text, const QTextDocument *_resourceP nodes.append(new QTextHtmlParserNode); txt = text; pos = 0; - len = txt.length(); + len = txt.size(); textEditMode = false; resourceProvider = _resourceProvider; parse(); @@ -672,7 +672,7 @@ void QTextHtmlParser::parseTag() resolveNode(); #ifndef QT_NO_CSSPARSER - const int nodeIndex = nodes.count() - 1; // this new node is always the last + const int nodeIndex = nodes.size() - 1; // this new node is always the last node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider); #endif applyAttributes(node->attributes); @@ -771,7 +771,7 @@ QString QTextHtmlParser::parseEntity(QStringView entity) if (!resolved.isNull()) return QString(resolved); - if (entity.length() > 1 && entity.at(0) == u'#') { + if (entity.size() > 1 && entity.at(0) == u'#') { entity = entity.mid(1); // removing leading # int base = 10; @@ -838,7 +838,7 @@ QString QTextHtmlParser::parseWord() while (pos < len) { QChar c = txt.at(pos++); // Allow for escaped single quotes as they may be part of the string - if (c == u'\'' && (txt.length() > 1 && txt.at(pos - 2) != u'\\')) + if (c == u'\'' && (txt.size() > 1 && txt.at(pos - 2) != u'\\')) break; else word += c; @@ -876,21 +876,21 @@ QTextHtmlParserNode *QTextHtmlParser::resolveParent() n = at(n).parent; if (!n) { - nodes.insert(nodes.count() - 1, new QTextHtmlParserNode); - nodes.insert(nodes.count() - 1, new QTextHtmlParserNode); + nodes.insert(nodes.size() - 1, new QTextHtmlParserNode); + nodes.insert(nodes.size() - 1, new QTextHtmlParserNode); - QTextHtmlParserNode *table = nodes[nodes.count() - 3]; + QTextHtmlParserNode *table = nodes[nodes.size() - 3]; table->parent = p; table->id = Html_table; table->tag = "table"_L1; - table->children.append(nodes.count() - 2); // add row as child + table->children.append(nodes.size() - 2); // add row as child - QTextHtmlParserNode *row = nodes[nodes.count() - 2]; - row->parent = nodes.count() - 3; // table as parent + QTextHtmlParserNode *row = nodes[nodes.size() - 2]; + row->parent = nodes.size() - 3; // table as parent row->id = Html_tr; row->tag = "tr"_L1; - p = nodes.count() - 2; + p = nodes.size() - 2; node = nodes.last(); // re-initialize pointer } } @@ -901,12 +901,12 @@ QTextHtmlParserNode *QTextHtmlParser::resolveParent() n = at(n).parent; if (!n) { - nodes.insert(nodes.count() - 1, new QTextHtmlParserNode); - QTextHtmlParserNode *table = nodes[nodes.count() - 2]; + nodes.insert(nodes.size() - 1, new QTextHtmlParserNode); + QTextHtmlParserNode *table = nodes[nodes.size() - 2]; table->parent = p; table->id = Html_table; table->tag = "table"_L1; - p = nodes.count() - 2; + p = nodes.size() - 2; node = nodes.last(); // re-initialize pointer } } @@ -954,7 +954,7 @@ QTextHtmlParserNode *QTextHtmlParser::resolveParent() node->parent = p; // makes it easier to traverse the tree, later - nodes[p]->children.append(nodes.count() - 1); + nodes[p]->children.append(nodes.size() - 1); return node; } @@ -1029,7 +1029,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent // set element specific attributes switch (id) { case Html_a: - for (int i = 0; i < attributes.count(); i += 2) { + for (int i = 0; i < attributes.size(); i += 2) { const QString key = attributes.at(i); if (key.compare("href"_L1, Qt::CaseInsensitive) == 0 && !attributes.at(i + 1).isEmpty()) { @@ -1117,7 +1117,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent #ifndef QT_NO_CSSPARSER void QTextHtmlParserNode::setListStyle(const QList<QCss::Value> &cssValues) { - for (int i = 0; i < cssValues.count(); ++i) { + for (int i = 0; i < cssValues.size(); ++i) { if (cssValues.at(i).type == QCss::Value::KnownIdentifier) { switch (static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) { case QCss::Value_None: hasOwnListStyle = true; listStyle = QTextListFormat::ListStyleUndefined; break; @@ -1200,7 +1200,7 @@ void QTextHtmlParserNode::applyCssDeclarations(const QList<QCss::Declaration> &d } } - for (int i = 0; i < declarations.count(); ++i) { + for (int i = 0; i < declarations.size(); ++i) { const QCss::Declaration &decl = declarations.at(i); if (decl.d->values.isEmpty()) continue; @@ -1487,7 +1487,7 @@ void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDo bool QTextHtmlParserNode::hasOnlyWhitespace() const { - for (int i = 0; i < text.length(); ++i) + for (int i = 0; i < text.size(); ++i) if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator) return false; return true; @@ -1537,7 +1537,7 @@ void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextD QCss::Parser parser(css); QCss::StyleSheet sheet; parser.parse(&sheet, Qt::CaseInsensitive); - if (sheet.styleRules.count() != 1) return; + if (sheet.styleRules.size() != 1) return; applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider); } #endif @@ -1575,12 +1575,12 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) QString linkHref; QString linkType; - if (attributes.count() % 2 == 1) + if (attributes.size() % 2 == 1) return; QTextHtmlParserNode *node = nodes.last(); - for (int i = 0; i < attributes.count(); i += 2) { + for (int i = 0; i < attributes.size(); i += 2) { QString key = attributes.at(i); QString value = attributes.at(i + 1); @@ -1900,7 +1900,7 @@ void QTextHtmlStyleSelector::freeNode(NodePtr) const void QTextHtmlParser::resolveStyleSheetImports(const QCss::StyleSheet &sheet) { - for (int i = 0; i < sheet.importRules.count(); ++i) { + for (int i = 0; i < sheet.importRules.size(); ++i) { const QCss::ImportRule &rule = sheet.importRules.at(i); if (rule.media.isEmpty() || rule.media.contains("screen"_L1, Qt::CaseInsensitive)) importStyleSheet(rule.href); @@ -1911,7 +1911,7 @@ void QTextHtmlParser::importStyleSheet(const QString &href) { if (!resourceProvider) return; - for (int i = 0; i < externalStyleSheets.count(); ++i) + for (int i = 0; i < externalStyleSheets.size(); ++i) if (externalStyleSheets.at(i).url == href) return; @@ -1942,7 +1942,7 @@ QList<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode &n case Html_u: { bool needsUnderline = (node.id == Html_u) ? true : false; if (node.id == Html_a) { - for (int i = 0; i < node.attributes.count(); i += 2) { + for (int i = 0; i < node.attributes.size(); i += 2) { const QString key = node.attributes.at(i); if (key.compare("href"_L1, Qt::CaseInsensitive) == 0 && !node.attributes.at(i + 1).isEmpty()) { @@ -2117,15 +2117,15 @@ QList<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const int idx = 0; selector.styleSheets.resize((resourceProvider ? 1 : 0) - + externalStyleSheets.count() - + inlineStyleSheets.count()); + + externalStyleSheets.size() + + inlineStyleSheets.size()); if (resourceProvider) selector.styleSheets[idx++] = QTextDocumentPrivate::get(resourceProvider)->parsedDefaultStyleSheet; - for (int i = 0; i < externalStyleSheets.count(); ++i, ++idx) + for (int i = 0; i < externalStyleSheets.size(); ++i, ++idx) selector.styleSheets[idx] = externalStyleSheets.at(i).sheet; - for (int i = 0; i < inlineStyleSheets.count(); ++i, ++idx) + for (int i = 0; i < inlineStyleSheets.size(); ++i, ++idx) selector.styleSheets[idx] = inlineStyleSheets.at(i); selector.medium = resourceProvider ? resourceProvider->metaInformation(QTextDocument::CssMedia) : "screen"_L1; diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index 5eb2e0683a..b26862da7f 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -252,8 +252,8 @@ public: inline const QTextHtmlParserNode &at(int i) const { return *nodes.at(i); } inline QTextHtmlParserNode &operator[](int i) { return *nodes[i]; } - inline int count() const { return nodes.count(); } - inline int last() const { return nodes.count()-1; } + inline int count() const { return nodes.size(); } + inline int last() const { return nodes.size()-1; } int depth(int i) const; int topMargin(int i) const; int bottomMargin(int i) const; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index eaf4bb4318..e3c69db7e5 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -627,8 +627,8 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const { const QCharAttributes *attributes = d->attributes(); int len = d->block.isValid() ? d->block.length() - 1 - : d->layoutData->string.length(); - Q_ASSERT(len <= d->layoutData->string.length()); + : d->layoutData->string.size(); + Q_ASSERT(len <= d->layoutData->string.size()); if (!attributes || oldPos < 0 || oldPos >= len) return oldPos; @@ -663,8 +663,8 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const { const QCharAttributes *attributes = d->attributes(); int len = d->block.isValid() ? d->block.length() - 1 - : d->layoutData->string.length(); - Q_ASSERT(len <= d->layoutData->string.length()); + : d->layoutData->string.size(); + Q_ASSERT(len <= d->layoutData->string.size()); if (!attributes || oldPos <= 0 || oldPos > len) return oldPos; @@ -735,7 +735,7 @@ int QTextLayout::leftCursorPosition(int oldPos) const bool QTextLayout::isValidCursorPosition(int pos) const { const QCharAttributes *attributes = d->attributes(); - if (!attributes || pos < 0 || pos > (int)d->layoutData->string.length()) + if (!attributes || pos < 0 || pos > (int)d->layoutData->string.size()) return false; return attributes[pos].graphemeBoundary; } @@ -776,7 +776,7 @@ QTextLine QTextLayout::createLine() } } int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length + d->lines.at(l-1).trailingSpaces : 0; - int strlen = d->layoutData->string.length(); + int strlen = d->layoutData->string.size(); if (l && from >= strlen) { if (!d->lines.at(l-1).length || d->layoutData->string.at(strlen - 1) != QChar::LineSeparator) return QTextLine(); @@ -979,7 +979,7 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const if (from < 0) from = 0; if (length < 0) - length = text().length(); + length = text().size(); QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphRunHash; for (int i=0; i<d->lines.size(); ++i) { @@ -1232,7 +1232,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition QPointF position = pos + d->position; - cursorPosition = qBound(0, cursorPosition, d->layoutData->string.length()); + cursorPosition = qBound(0, cursorPosition, d->layoutData->string.size()); int line = d->lineNumberForTextPosition(cursorPosition); if (line < 0) line = 0; @@ -1265,7 +1265,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition int neighborItem = itm; if (neighborItem > 0 && si->position == realCursorPosition) --neighborItem; - else if (neighborItem < d->layoutData->items.count() - 1 && si->position + si->num_glyphs == realCursorPosition) + else if (neighborItem < d->layoutData->items.size() - 1 && si->position + si->num_glyphs == realCursorPosition) ++neighborItem; const bool onBoundary = neighborItem != itm && si->analysis.bidiLevel != d->layoutData->items[neighborItem].analysis.bidiLevel; @@ -1560,7 +1560,7 @@ void QTextLine::setLineWidth(qreal width) line.width = QFixed::fromReal(width); if (line.length && line.textWidth <= line.width - && line.from + line.length == eng->layoutData->string.length()) + && line.from + line.length == eng->layoutData->string.size()) // no need to do anything if the line is already layouted and the last one. This optimization helps // when using things in a single line layout. return; @@ -1776,12 +1776,12 @@ void QTextLine::layout_helper(int maxGlyphs) line.textWidth = 0; line.hasTrailingSpaces = false; - if (!eng->layoutData->items.size() || line.from >= eng->layoutData->string.length()) { + if (!eng->layoutData->items.size() || line.from >= eng->layoutData->string.size()) { line.setDefaultHeight(eng); return; } - Q_ASSERT(line.from < eng->layoutData->string.length()); + Q_ASSERT(line.from < eng->layoutData->string.size()); LineBreakHelper lbh; @@ -1936,11 +1936,11 @@ void QTextLine::layout_helper(int maxGlyphs) // spaces to behave as in previous Qt versions in the line breaking algorithm. // The line breaks do not currently follow the Unicode specs, but fixing this would // require refactoring the code and would cause behavioral regressions. - const bool isBreakableSpace = lbh.currentPosition < eng->layoutData->string.length() + const bool isBreakableSpace = lbh.currentPosition < eng->layoutData->string.size() && attributes[lbh.currentPosition].whiteSpace && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak; - if (lbh.currentPosition >= eng->layoutData->string.length() + if (lbh.currentPosition >= eng->layoutData->string.size() || isBreakableSpace || attributes[lbh.currentPosition].lineBreak || lbh.tmpData.textWidth >= QFIXED_MAX) { @@ -2162,7 +2162,7 @@ int QTextLine::textStart() const int QTextLine::textLength() const { if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators - && eng->block.isValid() && index == eng->lines.count()-1) { + && eng->block.isValid() && index == eng->lines.size()-1) { return eng->lines.at(index).length - 1; } return eng->lines.at(index).length + eng->lines.at(index).trailingSpaces; @@ -2770,7 +2770,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const int neighborItem = itm; if (neighborItem > 0 && scriptItem->position == pos) --neighborItem; - else if (neighborItem < eng->layoutData->items.count() - 1 && scriptItem->position + scriptItem->num_glyphs == pos) + else if (neighborItem < eng->layoutData->items.size() - 1 && scriptItem->position + scriptItem->num_glyphs == pos) ++neighborItem; const bool onBoundary = neighborItem != itm && scriptItem->analysis.bidiLevel != eng->layoutData->items[neighborItem].analysis.bidiLevel; // If we are, prioritise the neighbor item that has the same direction as the engine @@ -3087,7 +3087,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const // character between lines is a space and we want // to position the cursor to the left of that // character. - if (index < eng->lines.count() - 1) + if (index < eng->lines.size() - 1) pos = qMin(eng->previousLogicalPosition(pos), pos); return pos; diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp index fc61e54cda..bdd2b0f5b7 100644 --- a/src/gui/text/qtextlist.cpp +++ b/src/gui/text/qtextlist.cpp @@ -86,7 +86,7 @@ QTextList::~QTextList() int QTextList::count() const { Q_D(const QTextList); - return d->blocks.count(); + return d->blocks.size(); } /*! diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index a839ca9623..14f1d9054f 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -148,7 +148,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) switch (blockType) { case MD_BLOCK_P: if (!m_listStack.isEmpty()) - qCDebug(lcMD, m_listItem ? "P of LI at level %d" : "P continuation inside LI at level %d", int(m_listStack.count())); + qCDebug(lcMD, m_listItem ? "P of LI at level %d" : "P continuation inside LI at level %d", int(m_listStack.size())); else qCDebug(lcMD, "P"); m_needsInsertBlock = true; @@ -202,7 +202,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_needsInsertList = true; MD_BLOCK_UL_DETAIL *detail = static_cast<MD_BLOCK_UL_DETAIL *>(det); m_listFormat = QTextListFormat(); - m_listFormat.setIndent(m_listStack.count() + 1); + m_listFormat.setIndent(m_listStack.size() + 1); switch (detail->mark) { case '*': m_listFormat.setStyle(QTextListFormat::ListCircle); @@ -214,7 +214,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_listFormat.setStyle(QTextListFormat::ListDisc); break; } - qCDebug(lcMD, "UL %c level %d", detail->mark, int(m_listStack.count()) + 1); + qCDebug(lcMD, "UL %c level %d", detail->mark, int(m_listStack.size()) + 1); } break; case MD_BLOCK_OL: { if (m_needsInsertList) // list nested in an empty list @@ -223,10 +223,10 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_needsInsertList = true; MD_BLOCK_OL_DETAIL *detail = static_cast<MD_BLOCK_OL_DETAIL *>(det); m_listFormat = QTextListFormat(); - m_listFormat.setIndent(m_listStack.count() + 1); + m_listFormat.setIndent(m_listStack.size() + 1); m_listFormat.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter)); m_listFormat.setStyle(QTextListFormat::ListDecimal); - qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, int(m_listStack.count()) + 1); + qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, int(m_listStack.size()) + 1); } break; case MD_BLOCK_TD: { MD_BLOCK_TD_DETAIL *detail = static_cast<MD_BLOCK_TD_DETAIL *>(det); @@ -297,7 +297,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) if (Q_UNLIKELY(m_listStack.isEmpty())) { qCWarning(lcMD, "list ended unexpectedly"); } else { - qCDebug(lcMD, "list at level %d ended", int(m_listStack.count())); + qCDebug(lcMD, "list at level %d ended", int(m_listStack.size())); m_listStack.pop(); } break; @@ -334,7 +334,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) m_cursor->movePosition(QTextCursor::End); break; case MD_BLOCK_LI: - qCDebug(lcMD, "LI at level %d ended", int(m_listStack.count())); + qCDebug(lcMD, "LI at level %d ended", int(m_listStack.size())); m_listItem = false; break; case MD_BLOCK_CODE: { @@ -591,7 +591,7 @@ void QTextMarkdownImporter::insertBlock() else blockFormat.setMarker(m_markerType); if (!m_listStack.isEmpty()) - blockFormat.setIndent(m_listStack.count()); + blockFormat.setIndent(m_listStack.size()); if (m_doc->isEmpty()) { m_cursor->setBlockFormat(blockFormat); m_cursor->setCharFormat(charFormat); diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index a5d8f4cc97..036d590e01 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -47,20 +47,20 @@ void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) { QList<int> tableColumnWidths(table->columnCount()); for (int col = 0; col < table->columnCount(); ++col) { - tableColumnWidths[col] = table->headerData(col, Qt::Horizontal).toString().length(); + tableColumnWidths[col] = table->headerData(col, Qt::Horizontal).toString().size(); for (int row = 0; row < table->rowCount(); ++row) { tableColumnWidths[col] = qMax(tableColumnWidths[col], - table->data(table->index(row, col)).toString().length()); + table->data(table->index(row, col)).toString().size()); } } // write the header and separator for (int col = 0; col < table->columnCount(); ++col) { QString s = table->headerData(col, Qt::Horizontal).toString(); - m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); + m_stream << "|" << s << QString(tableColumnWidths[col] - s.size(), Space); } m_stream << "|" << Qt::endl; - for (int col = 0; col < tableColumnWidths.length(); ++col) + for (int col = 0; col < tableColumnWidths.size(); ++col) m_stream << '|' << QString(tableColumnWidths[col], u'-'); m_stream << '|'<< Qt::endl; @@ -68,7 +68,7 @@ void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) for (int row = 0; row < table->rowCount(); ++row) { for (int col = 0; col < table->columnCount(); ++col) { QString s = table->data(table->index(row, col)).toString(); - m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); + m_stream << "|" << s << QString(tableColumnWidths[col] - s.size(), Space); } m_stream << '|'<< Qt::endl; } @@ -95,7 +95,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) while (it != cell.end()) { QTextBlock block = it.currentBlock(); if (block.isValid()) - cellTextLen += block.text().length(); + cellTextLen += block.text().size(); ++it; } if (cell.columnSpan() == 1 && tableColumnWidths[col] < cellTextLen) @@ -131,7 +131,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) if (tableRow < cell.row()) { if (tableRow == 0) { m_stream << Newline; - for (int col = 0; col < tableColumnWidths.length(); ++col) + for (int col = 0; col < tableColumnWidths.size(); ++col) m_stream << '|' << QString(tableColumnWidths[col], u'-'); m_stream << '|'; } @@ -213,7 +213,7 @@ QTextMarkdownWriter::ListInfo QTextMarkdownWriter::listInfo(QTextList *list) static int nearestWordWrapIndex(const QString &s, int before) { - before = qMin(before, s.length()); + before = qMin(before, s.size()); int fragBegin = qMax(before - 15, 0); if (lcMDW().isDebugEnabled()) { QString frag = s.mid(fragBegin, 30); @@ -232,7 +232,7 @@ static int nearestWordWrapIndex(const QString &s, int before) static int adjacentBackticksCount(const QString &s) { - int start = -1, len = s.length(); + int start = -1, len = s.size(); int ret = 0; for (int i = 0; i < len; ++i) { if (s.at(i) == Backtick) { @@ -334,7 +334,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign QTextBlockFormat blockFmt = block.blockFormat(); bool missedBlankCodeBlockLine = false; const bool codeBlock = blockFmt.hasProperty(QTextFormat::BlockCodeFence) || - blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0 || + blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).size() > 0 || blockFmt.nonBreakableLines(); if (m_fencedCodeBlock && !codeBlock) { m_stream << m_linePrefix << m_codeBlockFence << Newline; @@ -391,7 +391,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign if (suffix.isEmpty()) suffix = QString(Period); QString numberStr = QString::number(number) + suffix + Space; - if (numberStr.length() == 3) + if (numberStr.size() == 3) numberStr += Space; prefix += numberStr; } else { @@ -444,7 +444,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign // It would be convenient if QTextStream had a lineCharPos() accessor, // to keep track of how many characters (not bytes) have been written on the current line, // but it doesn't. So we have to keep track with this col variable. - int col = wrapIndentString.length(); + int col = wrapIndentString.size(); bool mono = false; bool startsOrEndsWithBacktick = false; bool bold = false; @@ -477,12 +477,12 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign if (!title.isEmpty()) s += Space + DoubleQuote + title + DoubleQuote; s += u')'; - if (wrap && col + s.length() > ColumnLimit) { + if (wrap && col + s.size() > ColumnLimit) { m_stream << Newline << wrapIndentString; col = m_wrappedLineIndent; } m_stream << s; - col += s.length(); + col += s.size(); } else if (fmt.hasProperty(QTextFormat::AnchorHref)) { const auto href = fmt.property(QTextFormat::AnchorHref).toString(); const bool hasToolTip = fmt.hasProperty(QTextFormat::TextToolTip); @@ -497,12 +497,12 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign } s += u')'; } - if (wrap && col + s.length() > ColumnLimit) { + if (wrap && col + s.size() > ColumnLimit) { m_stream << Newline << wrapIndentString; col = m_wrappedLineIndent; } m_stream << s; - col += s.length(); + col += s.size(); } else { QFontInfo fontInfo(fmt.font()); bool monoFrag = fontInfo.fixedPitch() || fmt.fontFixedPitch(); @@ -538,9 +538,9 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign } } } - if (wrap && col + markers.length() * 2 + fragmentText.length() > ColumnLimit) { + if (wrap && col + markers.size() * 2 + fragmentText.size() > ColumnLimit) { int i = 0; - const int fragLen = fragmentText.length(); + const int fragLen = fragmentText.size(); bool breakingLine = false; while (i < fragLen) { if (col >= ColumnLimit) { @@ -565,7 +565,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign QString subfrag = fragmentText.mid(i, j - i); if (!i) { m_stream << markers; - col += markers.length(); + col += markers.size(); } if (col == m_wrappedLineIndent) maybeEscapeFirstChar(subfrag); @@ -574,13 +574,13 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign m_stream << Newline << wrapIndentString; col = m_wrappedLineIndent; } else { - col += subfrag.length(); + col += subfrag.size(); } i = j + 1; } } else { m_stream << markers << fragmentText; - col += markers.length() + fragmentText.length(); + col += markers.size() + fragmentText.size(); } } } diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 7cf9d36a89..e7fd92928b 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -165,7 +165,7 @@ QTextDocument *QTextObject::document() const void QTextBlockGroupPrivate::markBlocksDirty() { - for (int i = 0; i < blocks.count(); ++i) { + for (int i = 0; i < blocks.size(); ++i) { const QTextBlock &block = blocks.at(i); pieceTable->documentChange(block.position(), block.length()); } diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index af1015883a..546859037c 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -262,17 +262,17 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc const int listLevel = block.textList()->format().indent(); if (m_listStack.isEmpty() || m_listStack.top() != block.textList()) { // not the same list we were in. - while (m_listStack.count() >= listLevel && !m_listStack.isEmpty() && m_listStack.top() != block.textList() ) { // we need to close tags + while (m_listStack.size() >= listLevel && !m_listStack.isEmpty() && m_listStack.top() != block.textList() ) { // we need to close tags m_listStack.pop(); writer.writeEndElement(); // list - if (m_listStack.count()) + if (m_listStack.size()) writer.writeEndElement(); // list-item } - while (m_listStack.count() < listLevel) { - if (m_listStack.count()) + while (m_listStack.size() < listLevel) { + if (m_listStack.size()) writer.writeStartElement(textNS, QString::fromLatin1("list-item")); writer.writeStartElement(textNS, QString::fromLatin1("list")); - if (m_listStack.count() == listLevel - 1) { + if (m_listStack.size() == listLevel - 1) { m_listStack.push(block.textList()); writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("L%1") .arg(block.textList()->formatIndex())); @@ -288,7 +288,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc while (! m_listStack.isEmpty()) { m_listStack.pop(); writer.writeEndElement(); // list - if (m_listStack.count()) + if (m_listStack.size()) writer.writeEndElement(); // list-item } } @@ -315,7 +315,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc writer.writeStartElement(textNS, QString::fromLatin1("span")); QString fragmentText = frag.fragment().text(); - if (fragmentText.length() == 1 && fragmentText[0] == u'\xFFFC') { // its an inline character. + if (fragmentText.size() == 1 && fragmentText[0] == u'\xFFFC') { // its an inline character. writeInlineCharacter(writer, frag.fragment()); writer.writeEndElement(); // span continue; @@ -326,8 +326,8 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc bool escapeNextSpace = true; int precedingSpaces = 0; int exportedIndex = 0; - for (int i=0; i <= fragmentText.length(); ++i) { - QChar character = (i == fragmentText.length() ? QChar() : fragmentText.at(i)); + for (int i=0; i <= fragmentText.size(); ++i) { + QChar character = (i == fragmentText.size() ? QChar() : fragmentText.at(i)); bool isSpace = character.unicode() == ' '; // find more than one space. -> <text:s text:c="2" /> @@ -343,7 +343,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc exportedIndex = i; } - if (i < fragmentText.length()) { + if (i < fragmentText.size()) { if (character.unicode() == 0x2028) { // soft-return //if (exportedIndex < i) writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex)); diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index c5d4874132..3e5b5bc000 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -109,7 +109,7 @@ void QTextOption::setTabArray(const QList<qreal> &tabStops) d = new QTextOptionPrivate; QList<QTextOption::Tab> tabs; QTextOption::Tab tab; - tabs.reserve(tabStops.count()); + tabs.reserve(tabStops.size()); for (qreal pos : tabStops) { tab.position = pos; tabs.append(tab); @@ -142,7 +142,7 @@ QList<qreal> QTextOption::tabArray() const if (!d) return answer; - answer.reserve(d->tabStops.count()); + answer.reserve(d->tabStops.size()); QList<QTextOption::Tab>::ConstIterator iter = d->tabStops.constBegin(); while(iter != d->tabStops.constEnd()) { answer.append( (*iter).position); diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 7728abccb7..64b7aa6765 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -939,7 +939,7 @@ void QTextTable::removeColumns(int pos, int num) QTextTableFormat tfmt = format(); tfmt.setColumns(tfmt.columns()-num); QList<QTextLength> columnWidths = tfmt.columnWidthConstraints(); - if (columnWidths.count() > pos) { + if (columnWidths.size() > pos) { columnWidths.remove(pos, num); tfmt.setColumnWidthConstraints (columnWidths); } diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index a3ef172902..7fd96363df 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -589,19 +589,19 @@ void QZipReaderPrivate::scanFiles() int l = readUShort(header.h.file_name_length); header.file_name = device->read(l); - if (header.file_name.length() != l) { + if (header.file_name.size() != l) { qWarning("QZip: Failed to read filename from zip index, index may be incomplete"); break; } l = readUShort(header.h.extra_field_length); header.extra_field = device->read(l); - if (header.extra_field.length() != l) { + if (header.extra_field.size() != l) { qWarning("QZip: Failed to read extra field in zip file, skipping file, index may be incomplete"); break; } l = readUShort(header.h.file_comment_length); header.file_comment = device->read(l); - if (header.file_comment.length() != l) { + if (header.file_comment.size() != l) { qWarning("QZip: Failed to read read file comment, index may be incomplete"); break; } @@ -630,7 +630,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const // don't compress small files QZipWriter::CompressionPolicy compression = compressionPolicy; if (compressionPolicy == QZipWriter::AutoCompress) { - if (contents.length() < 64) + if (contents.size() < 64) compression = QZipWriter::NeverCompress; else compression = QZipWriter::AlwaysCompress; @@ -641,19 +641,19 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const writeUInt(header.h.signature, 0x02014b50); writeUShort(header.h.version_needed, ZIP_VERSION); - writeUInt(header.h.uncompressed_size, contents.length()); + writeUInt(header.h.uncompressed_size, contents.size()); writeMSDosDate(header.h.last_mod_file, QDateTime::currentDateTime()); QByteArray data = contents; if (compression == QZipWriter::AlwaysCompress) { writeUShort(header.h.compression_method, CompressionMethodDeflated); - ulong len = contents.length(); + ulong len = contents.size(); // shamelessly copied form zlib len += (len >> 12) + (len >> 14) + 11; int res; do { data.resize(len); - res = deflate((uchar*)data.data(), &len, (const uchar*)contents.constData(), contents.length()); + res = deflate((uchar*)data.data(), &len, (const uchar*)contents.constData(), contents.size()); switch (res) { case Z_OK: @@ -670,9 +670,9 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const } while (res == Z_BUF_ERROR); } // TODO add a check if data.length() > contents.length(). Then try to store the original and revert the compression method to be uncompressed - writeUInt(header.h.compressed_size, data.length()); + writeUInt(header.h.compressed_size, data.size()); uint crc_32 = ::crc32(0, nullptr, 0); - crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.length()); + crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.size()); writeUInt(header.h.crc_32, crc_32); // if bit 11 is set, the filename and comment fields must be encoded using UTF-8 @@ -689,7 +689,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const qWarning("QZip: File comment is too long, chopping it to 65535 bytes"); header.file_comment.truncate(0xffff - header.file_name.size()); // ### don't break the utf-8 sequence, if any } - writeUShort(header.h.file_name_length, header.file_name.length()); + writeUShort(header.h.file_name_length, header.file_name.size()); //h.extra_field_length[2]; writeUShort(header.h.version_made, HostUnix << 8); @@ -878,7 +878,7 @@ QList<QZipReader::FileInfo> QZipReader::fileInfoList() const int QZipReader::count() const { d->scanFiles(); - return d->fileHeaders.count(); + return d->fileHeaders.size(); } /*! @@ -891,7 +891,7 @@ int QZipReader::count() const QZipReader::FileInfo QZipReader::entryInfoAt(int index) const { d->scanFiles(); - if (index >= 0 && index < d->fileHeaders.count()) + if (index >= 0 && index < d->fileHeaders.size()) return d->fillFileInfo(index); return QZipReader::FileInfo(); } @@ -1340,7 +1340,7 @@ void QZipWriter::close() writeUShort(eod.num_dir_entries, d->fileHeaders.size()); writeUInt(eod.directory_size, dir_size); writeUInt(eod.dir_start_offset, d->start_of_directory); - writeUShort(eod.comment_length, d->comment.length()); + writeUShort(eod.comment_length, d->comment.size()); d->device->write((const char *)&eod, sizeof(EndOfDirectory)); d->device->write(d->comment); diff --git a/src/gui/util/qedidparser.cpp b/src/gui/util/qedidparser.cpp index 191eea710b..9724fbc59c 100644 --- a/src/gui/util/qedidparser.cpp +++ b/src/gui/util/qedidparser.cpp @@ -72,7 +72,7 @@ static QString lookupVendorIdInSystemDatabase(QByteArrayView id) bool QEdidParser::parse(const QByteArray &blob) { const quint8 *data = reinterpret_cast<const quint8 *>(blob.constData()); - const size_t length = blob.length(); + const size_t length = blob.size(); // Verify header if (length < 128) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 25c02cba51..1cc42d3260 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -16,7 +16,7 @@ using namespace Qt::StringLiterals; template<typename T> static void insertOrRemoveItems(QList<T> &items, int index, int delta) { - int count = items.count(); + int count = items.size(); if (index < count) { if (delta > 0) { items.insert(index, delta, T()); @@ -773,7 +773,7 @@ int QGridLayoutEngine::columnCount(Qt::Orientation orientation) const int QGridLayoutEngine::itemCount() const { - return q_items.count(); + return q_items.size(); } QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const @@ -818,7 +818,7 @@ void QGridLayoutEngine::setRowSpacing(int row, qreal spacing, Qt::Orientation or Q_ASSERT(row >= 0); QGridLayoutRowInfo &rowInfo = q_infos[orientation]; - if (row >= rowInfo.spacings.count()) + if (row >= rowInfo.spacings.size()) rowInfo.spacings.resize(row + 1); if (spacing >= 0) rowInfo.spacings[row].setUserValue(spacing); @@ -843,7 +843,7 @@ void QGridLayoutEngine::setRowStretchFactor(int row, int stretch, Qt::Orientatio maybeExpandGrid(row, -1, orientation); QGridLayoutRowInfo &rowInfo = q_infos[orientation]; - if (row >= rowInfo.stretches.count()) + if (row >= rowInfo.stretches.size()) rowInfo.stretches.resize(row + 1); rowInfo.stretches[row].setUserValue(stretch); } @@ -865,7 +865,7 @@ void QGridLayoutEngine::setRowSizeHint(Qt::SizeHint which, int row, qreal size, maybeExpandGrid(row, -1, orientation); QGridLayoutRowInfo &rowInfo = q_infos[orientation]; - if (row >= rowInfo.boxes.count()) + if (row >= rowInfo.boxes.size()) rowInfo.boxes.resize(row + 1); rowInfo.boxes[row].q_sizes(which) = size; } @@ -883,7 +883,7 @@ void QGridLayoutEngine::setRowAlignment(int row, Qt::Alignment alignment, maybeExpandGrid(row, -1, orientation); QGridLayoutRowInfo &rowInfo = q_infos[orientation]; - if (row >= rowInfo.alignments.count()) + if (row >= rowInfo.alignments.size()) rowInfo.alignments.resize(row + 1); rowInfo.alignments[row] = alignment; } @@ -992,7 +992,7 @@ void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbs ensureGeometries(contentsGeometry.size(), styleInfo); - for (int i = q_items.count() - 1; i >= 0; --i) { + for (int i = q_items.size() - 1; i >= 0; --i) { QGridLayoutItem *item = q_items.at(i); qreal x = q_xx.at(item->firstColumn()); @@ -1121,7 +1121,7 @@ void QGridLayoutEngine::transpose() { invalidate(); - for (int i = q_items.count() - 1; i >= 0; --i) + for (int i = q_items.size() - 1; i >= 0; --i) q_items.at(i)->transpose(); q_defaultSpacings.transpose(); @@ -1210,7 +1210,7 @@ void QGridLayoutEngine::maybeExpandGrid(int row, int column, Qt::Orientation ori int newGridColumnCount = internalGridColumnCount(); int newGridSize = newGridRowCount * newGridColumnCount; - if (newGridSize != q_grid.count()) { + if (newGridSize != q_grid.size()) { q_grid.resize(newGridSize); if (newGridColumnCount != oldGridColumnCount) { @@ -1232,7 +1232,7 @@ void QGridLayoutEngine::regenerateGrid() { q_grid.fill(nullptr); - for (int i = q_items.count() - 1; i >= 0; --i) { + for (int i = q_items.size() - 1; i >= 0; --i) { QGridLayoutItem *item = q_items.at(i); for (int j = item->firstRow(); j <= item->lastRow(); ++j) { @@ -1265,7 +1265,7 @@ void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation o q_infos[orientation].insertOrRemoveRows(row, delta); - for (int i = q_items.count() - 1; i >= 0; --i) + for (int i = q_items.size() - 1; i >= 0; --i) q_items.at(i)->insertOrRemoveRows(row, delta, orientation); q_grid.resize(internalGridRowCount() * internalGridColumnCount()); @@ -1406,7 +1406,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, } } } - if (row < rowInfo.boxes.count()) { + if (row < rowInfo.boxes.size()) { QGridLayoutBox rowBoxInfo = rowInfo.boxes.at(row); rowBoxInfo.normalize(); rowBox.q_minimumSize = qMax(rowBox.q_minimumSize, rowBoxInfo.q_minimumSize); @@ -1510,7 +1510,7 @@ void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const q_cachedEffectiveFirstRows = {columnCount, rowCount}; q_cachedEffectiveLastRows = {-1, -1}; - for (int i = q_items.count() - 1; i >= 0; --i) { + for (int i = q_items.size() - 1; i >= 0; --i) { const QGridLayoutItem *item = q_items.at(i); for (Qt::Orientation o : {Qt::Horizontal, Qt::Vertical}) { @@ -1556,7 +1556,7 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri bool QGridLayoutEngine::ensureDynamicConstraint() const { if (q_cachedConstraintOrientation == UnknownConstraint) { - for (int i = q_items.count() - 1; i >= 0; --i) { + for (int i = q_items.size() - 1; i >= 0; --i) { QGridLayoutItem *item = q_items.at(i); if (item->hasDynamicConstraint()) { Qt::Orientation itemConstraintOrientation = item->dynamicConstraintOrientation(); diff --git a/src/gui/util/qktxhandler.cpp b/src/gui/util/qktxhandler.cpp index 85e3428bf0..f7e0e60330 100644 --- a/src/gui/util/qktxhandler.cpp +++ b/src/gui/util/qktxhandler.cpp @@ -117,7 +117,7 @@ QTextureFileData QKtxHandler::read() texData.setNumFaces(decode(header->numberOfFaces)); const quint32 bytesOfKeyValueData = decode(header->bytesOfKeyValueData); - if (headerSize + bytesOfKeyValueData < quint64(buf.length())) // oob check + if (headerSize + bytesOfKeyValueData < quint64(buf.size())) // oob check texData.setKeyValueMetadata( decodeKeyValues(QByteArrayView(buf.data() + headerSize, bytesOfKeyValueData))); quint32 offset = headerSize + bytesOfKeyValueData; diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index ddd99b0ffc..e1fa900b84 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -117,8 +117,8 @@ bool QTextureFileData::isValid() const if (d->data.isEmpty() || d->size.isEmpty() || (!d->format && !d->internalFormat)) return false; - const int numFacesOffset = d->offsets.length(); - const int numFacesLength = d->lengths.length(); + const int numFacesOffset = d->offsets.size(); + const int numFacesLength = d->lengths.size(); if (numFacesOffset == 0 || numFacesLength == 0 || d->numFaces != numFacesOffset || d->numFaces != numFacesLength) return false; diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp index 94d97216c4..403833d421 100644 --- a/src/gui/util/qundostack.cpp +++ b/src/gui/util/qundostack.cpp @@ -286,7 +286,7 @@ void QUndoCommand::setText(const QString &text) int QUndoCommand::childCount() const { - return d->child_list.count(); + return d->child_list.size(); } /*! @@ -299,7 +299,7 @@ int QUndoCommand::childCount() const const QUndoCommand *QUndoCommand::child(int index) const { - if (index < 0 || index >= d->child_list.count()) + if (index < 0 || index >= d->child_list.size()) return nullptr; return d->child_list.at(index); } @@ -444,10 +444,10 @@ void QUndoStackPrivate::setIndex(int idx, bool clean) bool QUndoStackPrivate::checkUndoLimit() { - if (undo_limit <= 0 || !macro_stack.isEmpty() || undo_limit >= command_list.count()) + if (undo_limit <= 0 || !macro_stack.isEmpty() || undo_limit >= command_list.size()) return false; - int del_count = command_list.count() - undo_limit; + int del_count = command_list.size() - undo_limit; for (int i = 0; i < del_count; ++i) delete command_list.takeFirst(); @@ -1142,7 +1142,7 @@ void QUndoStack::beginMacro(const QString &text) } d->macro_stack.append(cmd); - if (d->macro_stack.count() == 1) { + if (d->macro_stack.size() == 1) { emit canUndoChanged(false); emit undoTextChanged(QString()); emit canRedoChanged(false); @@ -1191,7 +1191,7 @@ const QUndoCommand *QUndoStack::command(int index) const { Q_D(const QUndoStack); - if (index < 0 || index >= d->command_list.count()) + if (index < 0 || index >= d->command_list.size()) return nullptr; return d->command_list.at(index); } diff --git a/src/gui/vulkan/qbasicvulkanplatforminstance.cpp b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp index 55d13d966c..c2f549f39f 100644 --- a/src/gui/vulkan/qbasicvulkanplatforminstance.cpp +++ b/src/gui/vulkan/qbasicvulkanplatforminstance.cpp @@ -246,13 +246,13 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const // No clever stuff with QSet and friends: the order for layers matters // and the user-provided order must be kept. - for (int i = 0; i < m_enabledLayers.count(); ++i) { + for (int i = 0; i < m_enabledLayers.size(); ++i) { const QByteArray &layerName(m_enabledLayers[i]); if (!m_supportedLayers.contains(layerName)) m_enabledLayers.removeAt(i--); } qDebug(lcPlatVk) << "Enabling Vulkan instance layers:" << m_enabledLayers; - for (int i = 0; i < m_enabledExtensions.count(); ++i) { + for (int i = 0; i < m_enabledExtensions.size(); ++i) { const QByteArray &extName(m_enabledExtensions[i]); if (!m_supportedExtensions.contains(extName)) m_enabledExtensions.removeAt(i--); @@ -269,7 +269,7 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const for (const QByteArray &ba : qAsConst(m_enabledLayers)) layerNameVec.append(ba.constData()); if (!layerNameVec.isEmpty()) { - instInfo.enabledLayerCount = layerNameVec.count(); + instInfo.enabledLayerCount = layerNameVec.size(); instInfo.ppEnabledLayerNames = layerNameVec.constData(); } @@ -277,7 +277,7 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const for (const QByteArray &ba : qAsConst(m_enabledExtensions)) extNameVec.append(ba.constData()); if (!extNameVec.isEmpty()) { - instInfo.enabledExtensionCount = extNameVec.count(); + instInfo.enabledExtensionCount = extNameVec.size(); instInfo.ppEnabledExtensionNames = extNameVec.constData(); } diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index 29d6d0d5bd..dbeb22fcb2 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -335,7 +335,7 @@ void QVulkanWindow::setPhysicalDeviceIndex(int idx) qWarning("QVulkanWindow: Attempted to set physical device when already initialized"); return; } - const int count = availablePhysicalDevices().count(); + const int count = availablePhysicalDevices().size(); if (idx < 0 || idx >= count) { qWarning("QVulkanWindow: Invalid physical device index %d (total physical devices: %d)", idx, count); return; @@ -581,7 +581,7 @@ void QVulkanWindowPrivate::init() return; } - if (physDevIndex < 0 || physDevIndex >= physDevs.count()) { + if (physDevIndex < 0 || physDevIndex >= physDevs.size()) { qWarning("QVulkanWindow: Invalid physical device index; defaulting to 0"); physDevIndex = 0; } @@ -600,7 +600,7 @@ void QVulkanWindowPrivate::init() f->vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, queueFamilyProps.data()); gfxQueueFamilyIdx = uint32_t(-1); presQueueFamilyIdx = uint32_t(-1); - for (int i = 0; i < queueFamilyProps.count(); ++i) { + for (int i = 0; i < queueFamilyProps.size(); ++i) { const bool supportsPresent = inst->supportsPresent(physDev, i, q); qCDebug(lcGuiVk, "queue family %d: flags=0x%x count=%d supportsPresent=%d", i, queueFamilyProps[i].queueFlags, queueFamilyProps[i].queueCount, supportsPresent); @@ -613,7 +613,7 @@ void QVulkanWindowPrivate::init() presQueueFamilyIdx = gfxQueueFamilyIdx; } else { qCDebug(lcGuiVk, "No queue with graphics+present; trying separate queues"); - for (int i = 0; i < queueFamilyProps.count(); ++i) { + for (int i = 0; i < queueFamilyProps.size(); ++i) { if (gfxQueueFamilyIdx == uint32_t(-1) && (queueFamilyProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)) gfxQueueFamilyIdx = i; if (presQueueFamilyIdx == uint32_t(-1) && inst->supportsPresent(physDev, i, q)) @@ -699,7 +699,7 @@ void QVulkanWindowPrivate::init() devInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; devInfo.queueCreateInfoCount = queueInfo.size(); devInfo.pQueueCreateInfos = queueInfo.constData(); - devInfo.enabledExtensionCount = devExts.count(); + devInfo.enabledExtensionCount = devExts.size(); devInfo.ppEnabledExtensionNames = devExts.constData(); VkPhysicalDeviceFeatures features; @@ -2273,7 +2273,7 @@ void QVulkanWindowPrivate::finishBlockingReadback() VkPhysicalDevice QVulkanWindow::physicalDevice() const { Q_D(const QVulkanWindow); - if (d->physDevIndex < d->physDevs.count()) + if (d->physDevIndex < d->physDevs.size()) return d->physDevs[d->physDevIndex]; qWarning("QVulkanWindow: Physical device not available"); return VK_NULL_HANDLE; @@ -2289,7 +2289,7 @@ VkPhysicalDevice QVulkanWindow::physicalDevice() const const VkPhysicalDeviceProperties *QVulkanWindow::physicalDeviceProperties() const { Q_D(const QVulkanWindow); - if (d->physDevIndex < d->physDevProps.count()) + if (d->physDevIndex < d->physDevProps.size()) return &d->physDevProps[d->physDevIndex]; qWarning("QVulkanWindow: Physical device properties not available"); return nullptr; diff --git a/src/network/access/qhttpheaderparser.cpp b/src/network/access/qhttpheaderparser.cpp index 0a869f064f..d0df245b35 100644 --- a/src/network/access/qhttpheaderparser.cpp +++ b/src/network/access/qhttpheaderparser.cpp @@ -102,7 +102,7 @@ bool QHttpHeaderParser::parseStatus(QByteArrayView status) static const int spacePos = 8; static const char httpMagic[] = "HTTP/"; - if (status.length() < minLength + if (status.size() < minLength || !status.startsWith(httpMagic) || status.at(dotPos) != '.' || status.at(spacePos) != ' ') { diff --git a/src/network/access/qhttpmultipart.cpp b/src/network/access/qhttpmultipart.cpp index 27e3ae2201..f24c06dda3 100644 --- a/src/network/access/qhttpmultipart.cpp +++ b/src/network/access/qhttpmultipart.cpp @@ -317,11 +317,11 @@ void QHttpMultiPart::setBoundary(const QByteArray &boundary) qint64 QHttpPartPrivate::bytesAvailable() const { checkHeaderCreated(); - qint64 bytesAvailable = header.length(); + qint64 bytesAvailable = header.size(); if (bodyDevice) { bytesAvailable += bodyDevice->bytesAvailable() - readPointer; } else { - bytesAvailable += body.length() - readPointer; + bytesAvailable += body.size() - readPointer; } // the device might have closed etc., so make sure we do not return a negative value return qMax(bytesAvailable, (qint64) 0); @@ -331,7 +331,7 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize) { checkHeaderCreated(); qint64 bytesRead = 0; - qint64 headerDataCount = header.length(); + qint64 headerDataCount = header.size(); // read header if it has not been read yet if (readPointer < headerDataCount) { @@ -349,7 +349,7 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize) bytesRead += dataBytesRead; readPointer += dataBytesRead; } else { - qint64 contentBytesRead = qMin(body.length() - readPointer + headerDataCount, maxSize - bytesRead); + qint64 contentBytesRead = qMin(body.size() - readPointer + headerDataCount, maxSize - bytesRead); const char *contentData = body.constData(); // if this method is called several times, we need to find the // right offset in the content ourselves: @@ -364,11 +364,11 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize) qint64 QHttpPartPrivate::size() const { checkHeaderCreated(); - qint64 size = header.length(); + qint64 size = header.size(); if (bodyDevice) { size += bodyDevice->size(); } else { - size += body.length(); + size += body.size(); } return size; } @@ -404,7 +404,7 @@ QHttpMultiPartPrivate::QHttpMultiPartPrivate() : contentType(QHttpMultiPart::Mix + QByteArray::fromRawData(reinterpret_cast<char *>(random), sizeof(random)).toBase64(); // boundary must not be longer than 70 characters, see RFC 2046, section 5.1.1 - Q_ASSERT(boundary.length() <= 70); + Q_ASSERT(boundary.size() <= 70); } qint64 QHttpMultiPartIODevice::size() const @@ -413,8 +413,8 @@ qint64 QHttpMultiPartIODevice::size() const // including boundary (needed later in readData) if (deviceSize == -1) { qint64 currentSize = 0; - qint64 boundaryCount = multiPart->boundary.length(); - for (int a = 0; a < multiPart->parts.count(); a++) { + qint64 boundaryCount = multiPart->boundary.size(); + for (int a = 0; a < multiPart->parts.size(); a++) { partOffsets.append(currentSize); // 4 additional bytes for the "--" before and the "\r\n" after the boundary, // and 2 bytes for the "\r\n" after the content @@ -428,7 +428,7 @@ qint64 QHttpMultiPartIODevice::size() const bool QHttpMultiPartIODevice::isSequential() const { - for (int a = 0; a < multiPart->parts.count(); a++) { + for (int a = 0; a < multiPart->parts.size(); a++) { QIODevice *device = multiPart->parts.at(a).d->bodyDevice; // we are sequential if any of the bodyDevices of our parts are sequential; // when reading from a byte array, we are not sequential @@ -442,7 +442,7 @@ bool QHttpMultiPartIODevice::reset() { // Reset QIODevice's data QIODevice::reset(); - for (int a = 0; a < multiPart->parts.count(); a++) + for (int a = 0; a < multiPart->parts.size(); a++) if (!multiPart->parts[a].d->reset()) return false; readPointer = 0; @@ -453,17 +453,17 @@ qint64 QHttpMultiPartIODevice::readData(char *data, qint64 maxSize) qint64 bytesRead = 0, index = 0; // skip the parts we have already read - while (index < multiPart->parts.count() && + while (index < multiPart->parts.size() && readPointer >= partOffsets.at(index) + multiPart->parts.at(index).d->size() - + multiPart->boundary.length() + 6) // 6 == 2 boundary dashes, \r\n after boundary, \r\n after multipart + + multiPart->boundary.size() + 6) // 6 == 2 boundary dashes, \r\n after boundary, \r\n after multipart index++; // read the data - while (bytesRead < maxSize && index < multiPart->parts.count()) { + while (bytesRead < maxSize && index < multiPart->parts.size()) { // check whether we need to read the boundary of the current part QByteArray boundaryData = "--" + multiPart->boundary + "\r\n"; - qint64 boundaryCount = boundaryData.length(); + qint64 boundaryCount = boundaryData.size(); qint64 partIndex = readPointer - partOffsets.at(index); if (partIndex < boundaryCount) { qint64 boundaryBytesRead = qMin(boundaryCount - partIndex, maxSize - bytesRead); @@ -494,10 +494,10 @@ qint64 QHttpMultiPartIODevice::readData(char *data, qint64 maxSize) } } // check whether we need to return the final boundary - if (bytesRead < maxSize && index == multiPart->parts.count()) { + if (bytesRead < maxSize && index == multiPart->parts.size()) { QByteArray finalBoundary = "--" + multiPart->boundary + "--\r\n"; - qint64 boundaryIndex = readPointer + finalBoundary.length() - size(); - qint64 lastBoundaryBytesRead = qMin(finalBoundary.length() - boundaryIndex, maxSize - bytesRead); + qint64 boundaryIndex = readPointer + finalBoundary.size() - size(); + qint64 lastBoundaryBytesRead = qMin(finalBoundary.size() - boundaryIndex, maxSize - bytesRead); memcpy(data + bytesRead, finalBoundary.constData() + boundaryIndex, lastBoundaryBytesRead); bytesRead += lastBoundaryBytesRead; readPointer += lastBoundaryBytesRead; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 3b08a84a03..1f2b813a83 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -762,7 +762,7 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) if (channels[i].reply == nullptr) return; - if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) { + if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.size() >= defaultRePipelineLength)) { return; } @@ -803,28 +803,28 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) int lengthBefore; while (!highPriorityQueue.isEmpty()) { - lengthBefore = channels[i].alreadyPipelinedRequests.length(); + lengthBefore = channels[i].alreadyPipelinedRequests.size(); fillPipeline(highPriorityQueue, channels[i]); - if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { + if (channels[i].alreadyPipelinedRequests.size() >= defaultPipelineLength) { channels[i].pipelineFlush(); return; } - if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) + if (lengthBefore == channels[i].alreadyPipelinedRequests.size()) break; // did not process anything, now do the low prio queue } while (!lowPriorityQueue.isEmpty()) { - lengthBefore = channels[i].alreadyPipelinedRequests.length(); + lengthBefore = channels[i].alreadyPipelinedRequests.size(); fillPipeline(lowPriorityQueue, channels[i]); - if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { + if (channels[i].alreadyPipelinedRequests.size() >= defaultPipelineLength) { channels[i].pipelineFlush(); return; } - if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) + if (lengthBefore == channels[i].alreadyPipelinedRequests.size()) break; // did not process anything } @@ -838,7 +838,7 @@ bool QHttpNetworkConnectionPrivate::fillPipeline(QList<HttpMessagePair> &queue, if (queue.isEmpty()) return true; - for (int i = queue.count() - 1; i >= 0; --i) { + for (int i = queue.size() - 1; i >= 0; --i) { HttpMessagePair messagePair = queue.at(i); const QHttpNetworkRequest &request = messagePair.first; @@ -960,7 +960,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) } // is the reply inside the pipeline of this channel already? - for (int j = 0; j < channels[i].alreadyPipelinedRequests.length(); j++) { + for (int j = 0; j < channels[i].alreadyPipelinedRequests.size(); j++) { if (channels[i].alreadyPipelinedRequests.at(j).second == reply) { // Remove that HttpMessagePair channels[i].alreadyPipelinedRequests.removeAt(j); @@ -994,7 +994,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) } // remove from the high priority queue if (!highPriorityQueue.isEmpty()) { - for (int j = highPriorityQueue.count() - 1; j >= 0; --j) { + for (int j = highPriorityQueue.size() - 1; j >= 0; --j) { HttpMessagePair messagePair = highPriorityQueue.at(j); if (messagePair.second == reply) { highPriorityQueue.removeAt(j); @@ -1005,7 +1005,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) } // remove from the low priority queue if (!lowPriorityQueue.isEmpty()) { - for (int j = lowPriorityQueue.count() - 1; j >= 0; --j) { + for (int j = lowPriorityQueue.size() - 1; j >= 0; --j) { HttpMessagePair messagePair = lowPriorityQueue.at(j); if (messagePair.second == reply) { lowPriorityQueue.removeAt(j); @@ -1108,7 +1108,7 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() // If there is not already any connected channels we need to connect a new one. // We do not pair the channel with the request until we know if it is // connected or not. This is to reuse connected channels before we connect new once. - int queuedRequests = highPriorityQueue.count() + lowPriorityQueue.count(); + int queuedRequests = highPriorityQueue.size() + lowPriorityQueue.size(); // in case we have in-flight preconnect requests and normal requests, // we only need one socket for each (preconnect, normal request) pair @@ -1558,12 +1558,12 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN pauseConnection(); QHttpNetworkReply *reply; if ((connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2 - && (chan->switchedToHttp2 || chan->h2RequestsToSend.count() > 0)) + && (chan->switchedToHttp2 || chan->h2RequestsToSend.size() > 0)) || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) { // we choose the reply to emit the proxyAuth signal from somewhat arbitrarily, // but that does not matter because the signal will ultimately be emitted // by the QNetworkAccessManager. - Q_ASSERT(chan->h2RequestsToSend.count() > 0); + Q_ASSERT(chan->h2RequestsToSend.size() > 0); reply = chan->h2RequestsToSend.cbegin().value().second; } else { // HTTP reply = chan->reply; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index ed581eb7d8..1e036bdc45 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -325,7 +325,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection() QHttpNetworkReply *potentialReply = connection->d_func()->predictNextRequestsReply(); if (potentialReply) { QMetaObject::invokeMethod(potentialReply, "socketStartedConnecting", Qt::QueuedConnection); - } else if (h2RequestsToSend.count() > 0) { + } else if (h2RequestsToSend.size() > 0) { QMetaObject::invokeMethod(h2RequestsToSend.values().at(0).second, "socketStartedConnecting", Qt::QueuedConnection); } @@ -344,7 +344,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection() if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct || (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 - && h2RequestsToSend.count() > 0)) { + && h2RequestsToSend.size() > 0)) { value = h2RequestsToSend.first().first.headerField("user-agent"); } else { value = connection->d_func()->predictNextRequest().headerField("user-agent"); @@ -573,7 +573,7 @@ void QHttpNetworkConnectionChannel::detectPipeliningSupport() // called when the connection broke and we need to queue some pipelined requests again void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests() { - for (int i = 0; i < alreadyPipelinedRequests.length(); i++) + for (int i = 0; i < alreadyPipelinedRequests.size(); i++) connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i)); alreadyPipelinedRequests.clear(); @@ -829,7 +829,7 @@ void QHttpNetworkConnectionChannel::_q_disconnected() QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } state = QHttpNetworkConnectionChannel::IdleState; - if (alreadyPipelinedRequests.length()) { + if (alreadyPipelinedRequests.size()) { // If nothing was in a pipeline, no need in calling // _q_startNextRequest (which it does): requeueCurrentlyPipelinedRequests(); @@ -908,7 +908,7 @@ void QHttpNetworkConnectionChannel::_q_connected() } else if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) { state = QHttpNetworkConnectionChannel::IdleState; protocolHandler.reset(new QHttp2ProtocolHandler(this)); - if (h2RequestsToSend.count() > 0) { + if (h2RequestsToSend.size() > 0) { // In case our peer has sent us its settings (window size, max concurrent streams etc.) // let's give _q_receiveReply a chance to read them first ('invokeMethod', QueuedConnection). QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); @@ -1088,7 +1088,7 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) { QList<HttpMessagePair> h2Pairs = h2RequestsToSend.values(); - for (int a = 0; a < h2Pairs.count(); ++a) { + for (int a = 0; a < h2Pairs.size(); ++a) { // emit error for all replies QHttpNetworkReply *currentReply = h2Pairs.at(a).second; currentReply->d_func()->errorString = errorString; @@ -1120,9 +1120,9 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) { if ((connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 - && (switchedToHttp2 || h2RequestsToSend.count() > 0)) + && (switchedToHttp2 || h2RequestsToSend.size() > 0)) || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) { - if (h2RequestsToSend.count() > 0) + if (h2RequestsToSend.size() > 0) connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); } else { // HTTP // Need to dequeue the request before we can emit the error. @@ -1146,7 +1146,7 @@ void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::Network if (reply) emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); QList<HttpMessagePair> h2Pairs = h2RequestsToSend.values(); - for (int a = 0; a < h2Pairs.count(); ++a) { + for (int a = 0; a < h2Pairs.size(); ++a) { QHttpNetworkReply *currentReply = h2Pairs.at(a).second; Q_ASSERT(currentReply); emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); @@ -1228,7 +1228,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) { - if (h2RequestsToSend.count() > 0) { + if (h2RequestsToSend.size() > 0) { // Similar to HTTP/1.1 counterpart below: const auto &h2Pairs = h2RequestsToSend.values(); // (request, reply) const auto &pair = h2Pairs.first(); @@ -1253,7 +1253,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() void QHttpNetworkConnectionChannel::requeueHttp2Requests() { QList<HttpMessagePair> h2Pairs = h2RequestsToSend.values(); - for (int a = 0; a < h2Pairs.count(); ++a) + for (int a = 0; a < h2Pairs.size(); ++a) connection->d_func()->requeueRequest(h2Pairs.at(a)); h2RequestsToSend.clear(); } @@ -1275,7 +1275,7 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors) #ifndef QT_NO_SSL else { // HTTP/2 QList<HttpMessagePair> h2Pairs = h2RequestsToSend.values(); - for (int a = 0; a < h2Pairs.count(); ++a) { + for (int a = 0; a < h2Pairs.size(); ++a) { // emit SSL errors for all replies QHttpNetworkReply *currentReply = h2Pairs.at(a).second; Q_ASSERT(currentReply); @@ -1298,7 +1298,7 @@ void QHttpNetworkConnectionChannel::_q_preSharedKeyAuthenticationRequired(QSslPr emit reply->preSharedKeyAuthenticationRequired(authenticator); } else { QList<HttpMessagePair> h2Pairs = h2RequestsToSend.values(); - for (int a = 0; a < h2Pairs.count(); ++a) { + for (int a = 0; a < h2Pairs.size(); ++a) { // emit SSL errors for all replies QHttpNetworkReply *currentReply = h2Pairs.at(a).second; Q_ASSERT(currentReply); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index cb93d3e410..0d69dec980 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -420,7 +420,7 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) if (c == '\n') { // remove the CR at the end if (fragment.endsWith('\r')) { - fragment.truncate(fragment.length()-1); + fragment.truncate(fragment.size()-1); } bool ok = parseStatus(fragment); state = ReadingHeaderState; @@ -434,7 +434,7 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) } // is this a valid reply? - if (fragment.length() == 5 && !fragment.startsWith("HTTP/")) { + if (fragment.size() == 5 && !fragment.startsWith("HTTP/")) { fragment.clear(); return -1; } @@ -482,8 +482,8 @@ qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket) allHeaders = true; // there is another case: We have no headers. Then the fragment equals just the line ending - if ((fragment.length() == 2 && fragment.endsWith("\r\n")) - || (fragment.length() == 1 && fragment.endsWith("\n"))) + if ((fragment.size() == 2 && fragment.endsWith("\r\n")) + || (fragment.size() == 1 && fragment.endsWith("\n"))) allHeaders = true; } } diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index 8c90c92db9..d5e529f6b9 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -114,7 +114,7 @@ QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request { QList<QPair<QByteArray, QByteArray> > fields = request.header(); QByteArray ba; - ba.reserve(40 + fields.length()*25); // very rough lower bound estimation + ba.reserve(40 + fields.size()*25); // very rough lower bound estimation ba += request.methodName(); ba += ' '; diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 4b56870d15..2100c188a5 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -46,7 +46,7 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, #endif || url.isLocalFile()) { return new QNetworkAccessFileBackend; - } else if (!url.scheme().isEmpty() && url.authority().isEmpty() && (url.scheme().length() > 1)) { + } else if (!url.scheme().isEmpty() && url.authority().isEmpty() && (url.scheme().size() > 1)) { // check if QFile could, in theory, open this URL via the file engines // it has to be in the format: // prefix:path/to/file diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 435dec190c..c4d470753d 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1653,7 +1653,7 @@ QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkReq // add Content-Type header if not there already if (!request.header(QNetworkRequest::ContentTypeHeader).isValid()) { QByteArray contentType; - contentType.reserve(34 + multiPart->d_func()->boundary.length()); + contentType.reserve(34 + multiPart->d_func()->boundary.size()); contentType += "multipart/"; switch (multiPart->d_func()->contentType) { case QHttpMultiPart::RelatedType: diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 7ddce06360..b195609697 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -380,7 +380,7 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi // (1) token // (2) token = token // (3) token = quoted-string - const int length = text.length(); + const int length = text.size(); position = nextNonWhitespace(text, position); int semiColonPosition = text.indexOf(';', position); @@ -578,7 +578,7 @@ static bool checkStaticArray(int &val, const QByteArray &dateString, int at, con { if (dateString[at] < 'a' || dateString[at] > 'z') return false; - if (val == -1 && dateString.length() >= at + 3) { + if (val == -1 && dateString.size() >= at + 3) { int j = 0; int i = 0; while (i <= size) { @@ -636,7 +636,7 @@ static QDateTime parseDateString(const QByteArray &dateString) u"(\\d\\d?):(\\d\\d?)(?::(\\d\\d?)(?:\\.(\\d{1,3}))?)?(?:\\s*(am|pm))?"_s); int at = 0; - while (at < dateString.length()) { + while (at < dateString.size()) { #ifdef PARSEDATESTRINGDEBUG qDebug() << dateString.mid(at); #endif @@ -677,7 +677,7 @@ static QDateTime parseDateString(const QByteArray &dateString) && (dateString[at - 1] == 't')))) { int end = 1; - while (end < 5 && dateString.length() > at+end + while (end < 5 && dateString.size() > at+end && dateString[at + end] >= '0' && dateString[at + end] <= '9') ++end; int minutes = 0; @@ -709,7 +709,7 @@ static QDateTime parseDateString(const QByteArray &dateString) // Time if (isNum && time.isNull() - && dateString.length() >= at + 3 + && dateString.size() >= at + 3 && (dateString[at + 2] == ':' || dateString[at + 1] == ':')) { // While the date can be found all over the string the format // for the time is set and a nice regexp can be used. @@ -737,7 +737,7 @@ static QDateTime parseDateString(const QByteArray &dateString) // 4 digit Year if (isNum && year == -1 - && dateString.length() > at + 3) { + && dateString.size() > at + 3) { if (isNumber(dateString[at + 1]) && isNumber(dateString[at + 2]) && isNumber(dateString[at + 3])) { @@ -754,7 +754,7 @@ static QDateTime parseDateString(const QByteArray &dateString) // Could be month, day or year if (isNum) { int length = 1; - if (dateString.length() > at + 1 + if (dateString.size() > at + 1 && isNumber(dateString[at + 1])) ++length; int x = atoi(dateString.mid(at, length).constData()); @@ -953,7 +953,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt const QDateTime now = QDateTime::currentDateTimeUtc(); int position = 0; - const int length = cookieString.length(); + const int length = cookieString.size(); while (position < length) { QNetworkCookie cookie; @@ -974,7 +974,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive if (field.first == "expires") { - position -= field.second.length(); + position -= field.second.size(); int end; for (end = position; end < length; ++end) if (isValueSeparator(cookieString.at(end))) diff --git a/src/network/access/qnetworkcookie_p.h b/src/network/access/qnetworkcookie_p.h index cfbd846212..7874b2c16a 100644 --- a/src/network/access/qnetworkcookie_p.h +++ b/src/network/access/qnetworkcookie_p.h @@ -49,7 +49,7 @@ static int nextNonWhitespace(const QByteArray &text, int from) // LWS = [CRLF] 1*( SP | HT ) // We ignore the fact that CRLF must come as a pair at this point // It's an invalid HTTP header if that happens. - while (from < text.length()) { + while (from < text.size()) { if (isLWS(text.at(from))) ++from; else @@ -57,7 +57,7 @@ static int nextNonWhitespace(const QByteArray &text, int from) } // reached the end - return text.length(); + return text.size(); } QT_END_NAMESPACE diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index d63185fdd0..bbb62455a5 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -116,7 +116,7 @@ static inline bool isParentPath(const QString &path, const QString &reference) { if ((path.isEmpty() && reference == "/"_L1) || path.startsWith(reference)) { //The cookie-path and the request-path are identical. - if (path.length() == reference.length()) + if (path.size() == reference.size()) return true; //The cookie-path is a prefix of the request-path, and the last //character of the cookie-path is %x2F ("/"). @@ -125,7 +125,7 @@ static inline bool isParentPath(const QString &path, const QString &reference) //The cookie-path is a prefix of the request-path, and the first //character of the request-path that is not included in the cookie- //path is a %x2F ("/") character. - if (path.at(reference.length()) == u'/') + if (path.at(reference.size()) == u'/') return true; } return false; @@ -229,7 +229,7 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const // insert this cookie into result, sorted by path QList<QNetworkCookie>::Iterator insertIt = result.begin(); while (insertIt != result.end()) { - if (insertIt->path().length() < it->path().length()) { + if (insertIt->path().size() < it->path().size()) { // insert here insertIt = result.insert(insertIt, *it); break; diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index cf07f51d4c..53a443d41c 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -563,7 +563,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url) // convert sha1 to base36 form and return first 8 bytes for use as string const QByteArray id = QByteArray::number(*(qlonglong*)hash.data(), 36).left(8); // generates <one-char subdir>/<8-char filename.d> - uint code = (uint)id.at(id.length()-1) % 16; + uint code = (uint)id.at(id.size()-1) % 16; QString pathFragment = QString::number(code, 16) + u'/' + QLatin1StringView(id) + CACHE_POSTFIX; return pathFragment; diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index a753639b14..854f9c8e6b 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -54,7 +54,7 @@ static QHash<QByteArray, QByteArray> parseHttpOptionHeader(const QByteArray &hea while (true) { // skip spaces pos = nextNonWhitespace(header, pos); - if (pos == header.length()) + if (pos == header.size()) return result; // end of parsing // pos points to a non-whitespace @@ -68,7 +68,7 @@ static QHash<QByteArray, QByteArray> parseHttpOptionHeader(const QByteArray &hea // of the header, whichever comes first int end = comma; if (end == -1) - end = header.length(); + end = header.size(); if (equal != -1 && end > equal) end = equal; // equal sign comes before comma/end QByteArray key = QByteArray(header.constData() + pos, end - pos).trimmed().toLower(); @@ -78,26 +78,26 @@ static QHash<QByteArray, QByteArray> parseHttpOptionHeader(const QByteArray &hea // case: token "=" (token | quoted-string) // skip spaces pos = nextNonWhitespace(header, pos); - if (pos == header.length()) + if (pos == header.size()) // huh? Broken header return result; QByteArray value; - value.reserve(header.length() - pos); + value.reserve(header.size() - pos); if (header.at(pos) == '"') { // case: quoted-string // quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) // qdtext = <any TEXT except <">> // quoted-pair = "\" CHAR ++pos; - while (pos < header.length()) { + while (pos < header.size()) { char c = header.at(pos); if (c == '"') { // end of quoted text break; } else if (c == '\\') { ++pos; - if (pos >= header.length()) + if (pos >= header.size()) // broken header return result; c = header.at(pos); @@ -108,7 +108,7 @@ static QHash<QByteArray, QByteArray> parseHttpOptionHeader(const QByteArray &hea } } else { // case: token - while (pos < header.length()) { + while (pos < header.size()) { char c = header.at(pos); if (isSeparator(c)) break; @@ -1717,7 +1717,7 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe // Don't store Warning 1xx headers if (header == "warning") { QByteArray v = q->rawHeader(header); - if (v.length() == 3 + if (v.size() == 3 && v[0] == '1' && v[1] >= '0' && v[1] <= '9' && v[2] >= '0' && v[2] <= '9') diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 9edbd1ff10..74da880b3c 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -1157,7 +1157,7 @@ static QVariant parseCookieHeader(const QByteArray &raw) const QList<QByteArray> cookieList = raw.split(';'); for (const QByteArray &cookie : cookieList) { QList<QNetworkCookie> parsed = QNetworkCookie::parseCookies(cookie.trimmed()); - if (parsed.count() != 1) + if (parsed.size() != 1) return QVariant(); // invalid Cookie: header result += parsed; diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 4b9ed021be..91660cf2f7 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -657,7 +657,7 @@ QAuthenticatorPrivate::parseDigestAuthenticationChallenge(QByteArrayView challen QHash<QByteArray, QByteArray> options; // parse the challenge const char *d = challenge.data(); - const char *end = d + challenge.length(); + const char *end = d + challenge.size(); while (d < end) { while (d < end && (*d == ' ' || *d == '\n' || *d == '\r')) ++d; @@ -798,7 +798,7 @@ QByteArray QAuthenticatorPrivate::digestMd5Response(QByteArrayView challenge, QB ++nonceCount; QByteArray nonceCountString = QByteArray::number(nonceCount, 16); - while (nonceCountString.length() < 8) + while (nonceCountString.size() < 8) nonceCountString.prepend('0'); QByteArray nonce = options.value("nonce"); @@ -1079,7 +1079,7 @@ static int qEncodeNtlmString(QNtlmBuffer& buf, int offset, const QString& s, boo { if (!unicode) return qEncodeNtlmBuffer(buf, offset, s.toLatin1()); - buf.len = 2 * s.length(); + buf.len = 2 * s.size(); buf.maxLen = buf.len; buf.offset = (offset + 1) & ~1; return buf.offset + buf.len; @@ -1201,7 +1201,7 @@ static QByteArray qNtlmPhase1() static QByteArray qStringAsUcs2Le(const QString& src) { - QByteArray rc(2*src.length(), 0); + QByteArray rc(2*src.size(), 0); unsigned short *d = (unsigned short*)rc.data(); for (QChar ch : src) *d++ = qToLittleEndian(quint16(ch.unicode())); @@ -1214,7 +1214,7 @@ static QString qStringFromUcs2Le(QByteArray src) { Q_ASSERT(src.size() % 2 == 0); unsigned short *d = (unsigned short*)src.data(); - for (int i = 0; i < src.length() / 2; ++i) { + for (int i = 0; i < src.size() / 2; ++i) { d[i] = qFromLittleEndian(d[i]); } return QString((const QChar *)src.data(), src.size()/2); @@ -1256,7 +1256,7 @@ QByteArray qEncodeHmacMd5(QByteArray &key, QByteArrayView message) hash.reset(); // Adjust the key length to blockSize - if (blockSize < key.length()) { + if (blockSize < key.size()) { hash.addData(key); key = hash.result(); //MD5 will always return 16 bytes length output } @@ -1759,7 +1759,7 @@ static QByteArray qGssapiContinue(QAuthenticatorPrivate *ctx, QByteArrayView cha if (!challenge.isEmpty()) { inBuf.value = const_cast<char*>(challenge.data()); - inBuf.length = challenge.length(); + inBuf.length = challenge.size(); } majStat = gss_init_sec_context(&minStat, diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 2628286751..827b622ac0 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1054,14 +1054,14 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet) // parse the address manually auto parts = netStr.split(u'.'); - if (parts.isEmpty() || parts.count() > 4) + if (parts.isEmpty() || parts.size() > 4) return invalid; // invalid IPv4 address if (parts.constLast().isEmpty()) parts.removeLast(); quint32 addr = 0; - for (int i = 0; i < parts.count(); ++i) { + for (int i = 0; i < parts.size(); ++i) { bool ok; uint byteValue = parts.at(i).toUInt(&ok); if (!ok || byteValue > 255) @@ -1070,9 +1070,9 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet) addr <<= 8; addr += byteValue; } - addr <<= 8 * (4 - parts.count()); + addr <<= 8 * (4 - parts.size()); if (netmask == -1) { - netmask = 8 * parts.count(); + netmask = 8 * parts.size(); } else if (netmask == 0) { // special case here // x86's instructions "shr" and "shl" do not operate when diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 6a6519e9c1..02ea55ef4e 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -934,7 +934,7 @@ void QHostInfoLookupManager::rescheduleWithMutexHeld() if (!finishedLookups.isEmpty()) { // remove ID from aborted if it is in there - for (int i = 0; i < finishedLookups.length(); i++) { + for (int i = 0; i < finishedLookups.size(); i++) { abortedLookups.removeAll(finishedLookups.at(i)->id); } @@ -1002,7 +1002,7 @@ void QHostInfoLookupManager::abortLookup(int id) #if QT_CONFIG(thread) // is postponed? delete and return - for (int i = 0; i < postponedLookups.length(); i++) { + for (int i = 0; i < postponedLookups.size(); i++) { if (postponedLookups.at(i)->id == id) { delete postponedLookups.takeAt(i); return; @@ -1011,7 +1011,7 @@ void QHostInfoLookupManager::abortLookup(int id) #endif // is scheduled? delete and return - for (int i = 0; i < scheduledLookups.length(); i++) { + for (int i = 0; i < scheduledLookups.size(); i++) { if (scheduledLookups.at(i)->id == id) { delete scheduledLookups.takeAt(i); return; diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index 4c92e01c23..51fb23b547 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -186,7 +186,7 @@ void processNetlinkRequest(int sock, struct nlmsghdr *hdr, char *buf, size_t buf uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name) { uint index = 0; - if (name.length() >= IFNAMSIZ) + if (name.size() >= IFNAMSIZ) return index; int socket = qt_safe_socket(AF_INET, SOCK_DGRAM, 0); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 0c447e90a4..626d46d7bf 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -401,8 +401,8 @@ bool QLocalSocketPrivate::parseSockaddr(const struct ::sockaddr_un &addr, if (!name.isEmpty() && !toUtf16.hasError()) { //conversion encodes the trailing zeros. So, in case of non-abstract namespace we //chop them off as \0 character is not allowed in filenames - if (!abstractNamespace && (name.at(name.length() - 1) == QChar::fromLatin1('\0'))) { - int truncPos = name.length() - 1; + if (!abstractNamespace && (name.at(name.size() - 1) == QChar::fromLatin1('\0'))) { + int truncPos = name.size() - 1; while (truncPos > 0 && name.at(truncPos - 1) == QChar::fromLatin1('\0')) truncPos--; name.truncate(truncPos); diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 4b5e93e785..13db3e6232 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -729,10 +729,10 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const if (v.s_addr != 0 && sizeofv >= QT_SOCKOPTLEN_T(sizeof(v))) { QHostAddress ipv4(ntohl(v.s_addr)); QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces(); - for (int i = 0; i < ifaces.count(); ++i) { + for (int i = 0; i < ifaces.size(); ++i) { const QNetworkInterface &iface = ifaces.at(i); QList<QNetworkAddressEntry> entries = iface.addressEntries(); - for (int j = 0; j < entries.count(); ++j) { + for (int j = 0; j < entries.size(); ++j) { const QNetworkAddressEntry &entry = entries.at(j); if (entry.ip() == ipv4) return iface; @@ -752,7 +752,7 @@ bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInter struct in_addr v; if (iface.isValid()) { QList<QNetworkAddressEntry> entries = iface.addressEntries(); - for (int i = 0; i < entries.count(); ++i) { + for (int i = 0; i < entries.size(); ++i) { const QNetworkAddressEntry &entry = entries.at(i); const QHostAddress &ip = entry.ip(); if (ip.protocol() == QAbstractSocket::IPv4Protocol) { diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 74804f043f..b1bca2bf4d 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -154,11 +154,11 @@ static bool qt_socks5_set_host_name_and_port(const QString &hostname, quint16 po QByteArray encodedHostName = QUrl::toAce(hostname); QByteArray &buf = *pBuf; - if (encodedHostName.length() > 255) + if (encodedHostName.size() > 255) return false; buf.append(S5_DOMAINNAME); - buf.append(uchar(encodedHostName.length())); + buf.append(uchar(encodedHostName.size())); buf.append(encodedHostName); // add port diff --git a/src/network/ssl/qpassworddigestor.cpp b/src/network/ssl/qpassworddigestor.cpp index a6c6e7666c..a08702e7b6 100644 --- a/src/network/ssl/qpassworddigestor.cpp +++ b/src/network/ssl/qpassworddigestor.cpp @@ -126,7 +126,7 @@ Q_NETWORK_EXPORT QByteArray deriveKeyPbkdf2(QCryptographicHash::Algorithm algori quint32 currentIteration = 1; QMessageAuthenticationCode hmac(algorithm, data); QByteArray index(4, Qt::Uninitialized); - while (quint64(key.length()) < dkLen) { + while (quint64(key.size()) < dkLen) { hmac.addData(salt); qToBigEndian(currentIteration, index.data()); diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 80377f3426..4a99fe492e 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -218,15 +218,15 @@ bool QSslConfiguration::isNull() const d->peerVerifyMode == QSslSocket::AutoVerifyPeer && d->peerVerifyDepth == 0 && d->allowRootCertOnDemandLoading == true && - d->caCertificates.count() == 0 && - d->ciphers.count() == 0 && + d->caCertificates.size() == 0 && + d->ciphers.size() == 0 && d->ellipticCurves.isEmpty() && d->ephemeralServerKey.isNull() && d->dhParams == QSslDiffieHellmanParameters::defaultParameters() && d->localCertificateChain.isEmpty() && d->privateKey.isNull() && d->peerCertificate.isNull() && - d->peerCertificateChain.count() == 0 && + d->peerCertificateChain.size() == 0 && d->backendConfig.isEmpty() && d->sslOptions == QSslConfigurationPrivate::defaultSslOptions && d->sslSession.isNull() && diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index cd76517c25..4eefe43929 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2661,7 +2661,7 @@ bool QSslSocketPrivate::verifyErrorsHaveBeenIgnored() // was called) const auto &sslErrors = backend->tlsErrors(); doEmitSslError = false; - for (int a = 0; a < sslErrors.count(); a++) { + for (int a = 0; a < sslErrors.size(); a++) { if (!ignoreErrorsList.contains(sslErrors.at(a))) { doEmitSslError = true; break; @@ -2799,11 +2799,11 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize) QByteArray ret; ret.reserve(maxSize); ret.resize(buffer.peek(ret.data(), maxSize, transactionPos)); - if (ret.length() == maxSize) + if (ret.size() == maxSize) return ret; //peek at data in the plain socket if (plainSocket) - return ret + plainSocket->peek(maxSize - ret.length()); + return ret + plainSocket->peek(maxSize - ret.size()); return QByteArray(); } else { @@ -3031,7 +3031,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos qsizetype secondCnDot = cn.indexOf(u'.', firstCnDot+1); // Check at least 3 components - if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length())) + if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.size())) return false; // Check * is last character of 1st component (ie. there's a following .) diff --git a/src/opengl/qopengldebug.cpp b/src/opengl/qopengldebug.cpp index 522aa2dba7..b774d0a85e 100644 --- a/src/opengl/qopengldebug.cpp +++ b/src/opengl/qopengldebug.cpp @@ -1147,7 +1147,7 @@ void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Source QVarLengthArray<GLenum, 8> glTypes; QVarLengthArray<GLenum, 8> glSeverities; - if (ids.count() > 0) { + if (ids.size() > 0) { Q_ASSERT(severities == QOpenGLDebugMessage::AnySeverity); // The GL_KHR_debug extension says: @@ -1188,7 +1188,7 @@ void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Source CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Severity, severities, glSeverities) #undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS - const GLsizei idCount = ids.count(); + const GLsizei idCount = ids.size(); // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. const GLuint * const idPtr = idCount ? ids.constData() : nullptr; @@ -1504,9 +1504,9 @@ void QOpenGLDebugLogger::logMessage(const QOpenGLDebugMessage &debugMessage) QByteArray rawMessage = debugMessage.message().toUtf8(); rawMessage.append('\0'); - if (rawMessage.length() > d->maxMessageLength) { + if (rawMessage.size() > d->maxMessageLength) { qWarning("QOpenGLDebugLogger::logMessage(): message too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", int(rawMessage.length()), d->maxMessageLength); + " (%d bytes long, but the GL accepts up to %d bytes)", int(rawMessage.size()), d->maxMessageLength); rawMessage.resize(d->maxMessageLength - 1); rawMessage.append('\0'); } @@ -1556,9 +1556,9 @@ void QOpenGLDebugLogger::pushGroup(const QString &name, GLuint id, QOpenGLDebugM QByteArray rawName = name.toUtf8(); rawName.append('\0'); - if (rawName.length() > d->maxMessageLength) { + if (rawName.size() > d->maxMessageLength) { qWarning("QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", int(rawName.length()), d->maxMessageLength); + " (%d bytes long, but the GL accepts up to %d bytes)", int(rawName.size()), d->maxMessageLength); rawName.resize(d->maxMessageLength - 1); rawName.append('\0'); } diff --git a/src/opengl/qopenglengineshadermanager.cpp b/src/opengl/qopenglengineshadermanager.cpp index d37da00a87..4b0c9ffdcf 100644 --- a/src/opengl/qopenglengineshadermanager.cpp +++ b/src/opengl/qopenglengineshadermanager.cpp @@ -431,7 +431,7 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO newProg->program->setUniformValue(location, QT_MASK_TEXTURE_UNIT); } - if (cachedPrograms.count() > 30) { + if (cachedPrograms.size() > 30) { // The cache is full, so delete the last 5 programs in the list. // These programs will be least used, as a program us bumped to // the top of the list when it's used. diff --git a/src/opengl/qopenglframebufferobject.cpp b/src/opengl/qopenglframebufferobject.cpp index 7bb4f49f6e..a0034adf74 100644 --- a/src/opengl/qopenglframebufferobject.cpp +++ b/src/opengl/qopenglframebufferobject.cpp @@ -1053,7 +1053,7 @@ void QOpenGLFramebufferObject::addColorAttachment(const QSize &size, GLenum inte QOpenGLFramebufferObjectPrivate::ColorAttachment color(size, effectiveInternalFormat(internalFormat)); d->colorAttachments.append(color); - const int idx = d->colorAttachments.count() - 1; + const int idx = d->colorAttachments.size() - 1; if (d->requestedSamples == 0) { d->initTexture(idx); @@ -1134,7 +1134,7 @@ bool QOpenGLFramebufferObject::bind() if (d->format.samples() == 0) { // Create new textures to replace the ones stolen via takeTexture(). - for (int i = 0; i < d->colorAttachments.count(); ++i) { + for (int i = 0; i < d->colorAttachments.size(); ++i) { if (!d->colorAttachments.at(i).guard) d->initTexture(i); } @@ -1214,7 +1214,7 @@ QList<GLuint> QOpenGLFramebufferObject::textures() const QList<GLuint> ids; if (d->format.samples() != 0) return ids; - ids.reserve(d->colorAttachments.count()); + ids.reserve(d->colorAttachments.size()); for (const auto &color : d->colorAttachments) ids.append(color.guard ? color.guard->id() : 0); return ids; @@ -1266,7 +1266,7 @@ GLuint QOpenGLFramebufferObject::takeTexture(int colorAttachmentIndex) { Q_D(QOpenGLFramebufferObject); GLuint id = 0; - if (isValid() && d->format.samples() == 0 && d->colorAttachments.count() > colorAttachmentIndex) { + if (isValid() && d->format.samples() == 0 && d->colorAttachments.size() > colorAttachmentIndex) { QOpenGLContext *current = QOpenGLContext::currentContext(); if (current && current->shareGroup() == d->fbo_guard->group() && isBound()) release(); @@ -1491,7 +1491,7 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex) return QImage(); } - if (d->colorAttachments.count() <= colorAttachmentIndex) { + if (d->colorAttachments.size() <= colorAttachmentIndex) { qWarning("QOpenGLFramebufferObject::toImage() called for missing color attachment"); return QImage(); } diff --git a/src/opengl/qopenglshaderprogram.cpp b/src/opengl/qopenglshaderprogram.cpp index 3f4089c4d6..6dab8ed70a 100644 --- a/src/opengl/qopenglshaderprogram.cpp +++ b/src/opengl/qopenglshaderprogram.cpp @@ -629,7 +629,7 @@ bool QOpenGLShader::compileSourceCode(const char *source) // Append #line directive in order to compensate for text insertion lineDirective = QStringLiteral("#line %1\n").arg(versionDirectivePosition.line).toUtf8(); sourceChunks.append(lineDirective.constData()); - sourceChunkLengths.append(GLint(lineDirective.length())); + sourceChunkLengths.append(GLint(lineDirective.size())); } // Append rest of shader code @@ -3749,7 +3749,7 @@ bool QOpenGLShaderProgramPrivate::linkBinary() const QByteArray cacheKey = binaryProgram.cacheKey(); if (lcOpenGLProgramDiskCache().isEnabled(QtDebugMsg)) qCDebug(lcOpenGLProgramDiskCache, "program with %d shaders, cache key %s", - int(binaryProgram.shaders.count()), cacheKey.constData()); + int(binaryProgram.shaders.size()), cacheKey.constData()); bool needsCompile = true; if (binCache.load(cacheKey, q->programId())) { diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index 21574133dc..e804488005 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -120,7 +120,7 @@ QWindow *QFbScreen::topLevelAt(const QPoint & p) const int QFbScreen::windowCount() const { - return mWindowStack.count(); + return mWindowStack.size(); } void QFbScreen::setDirty(const QRect &rect) @@ -210,7 +210,7 @@ QRegion QFbScreen::doRedraw() QFbWindow *QFbScreen::windowForId(WId wid) const { - for (int i = 0; i < mWindowStack.count(); ++i) { + for (int i = 0; i < mWindowStack.size(); ++i) { if (mWindowStack[i]->winId() == wid) return mWindowStack[i]; } diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 6691659345..09375393a8 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -181,7 +181,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const int rotationAngle = 0; 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("rotate"_L1)) { QString rotateArg = args.at(i).section(u'=', 1, 1); bool ok; @@ -565,7 +565,7 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) // Until that use a temporary key. int key = m_currentData.trackingId; if (key == -1) - key = m_contacts.count(); + key = m_contacts.size(); m_contacts.insert(key, m_currentData); m_currentData = Contact(); @@ -774,7 +774,7 @@ void QEvdevTouchScreenData::reportPoints() // Map the coordinates based on the normalized position. QPA expects 'area' // to be in screen coordinates. - const int pointCount = m_touchPoints.count(); + const int pointCount = m_touchPoints.size(); for (int i = 0; i < pointCount; ++i) { QWindowSystemInterface::TouchPoint &tp(m_touchPoints[i]); diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 84a05f565e..c3196676eb 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -19,7 +19,7 @@ QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t s { const int id = qMax(0, slot); - for (int i = 0; i < m_points.count(); ++i) + for (int i = 0; i < m_points.size(); ++i) if (m_points.at(i).id == id) return &m_points[i]; @@ -146,7 +146,7 @@ void QLibInputTouch::processTouchUp(libinput_event_touch *e) tp->state = QEventPoint::State::Released; // There may not be a Frame event after the last Up. Work this around. QEventPoint::States s; - for (int i = 0; i < state->m_points.count(); ++i) + for (int i = 0; i < state->m_points.size(); ++i) s |= state->m_points.at(i).state; if (s == QEventPoint::State::Released) processTouchFrame(e); @@ -177,7 +177,7 @@ void QLibInputTouch::processTouchFrame(libinput_event_touch *e) QWindowSystemInterface::handleTouchEvent(nullptr, state->m_touchDevice, state->m_points, QGuiApplication::keyboardModifiers()); - for (int i = 0; i < state->m_points.count(); ++i) { + for (int i = 0; i < state->m_points.size(); ++i) { QWindowSystemInterface::TouchPoint &tp(state->m_points[i]); if (tp.state == QEventPoint::State::Released) state->m_points.removeAt(i--); diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index c7a1624ef5..89b6df605b 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -200,7 +200,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (userConnectorConfig.contains(QStringLiteral("virtualPos"))) { const QByteArray vpos = userConnectorConfig.value(QStringLiteral("virtualPos")).toByteArray(); const QByteArrayList vposComp = vpos.split(','); - if (vposComp.count() == 2) + if (vposComp.size() == 2) vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt()); } if (userConnectorConfig.value(QStringLiteral("primary")).toBool()) @@ -437,7 +437,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s", - connectorName.constData(), int(output.available_planes.count()), qPrintable(planeListStr)); + connectorName.constData(), int(output.available_planes.size()), qPrintable(planeListStr)); // This is for the EGLDevice/EGLStream backend. On some of those devices one // may want to target a pre-configured plane. It is probably useless for @@ -478,7 +478,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, const QStringList crtcPlanePairs = val.split(u':'); for (const QString &crtcPlanePair : crtcPlanePairs) { const QStringList values = crtcPlanePair.split(u','); - if (values.count() == 2 && uint(values[0].toInt()) == output.crtc_id) { + if (values.size() == 2 && uint(values[0].toInt()) == output.crtc_id) { uint planeId = values[1].toInt(); for (QKmsPlane &kmsplane : m_planes) { if (kmsplane.id == planeId) { @@ -719,7 +719,7 @@ void QKmsDevice::createScreens() siblings.append(s); virtualPositions.append(virtualPos); if (orderedScreen.vinfo.isPrimary) - primarySiblingIdx = siblings.count() - 1; + primarySiblingIdx = siblings.size() - 1; } else { registerScreen(s, orderedScreen.vinfo.isPrimary, virtualPos, QList<QPlatformScreen *>() << s); } @@ -727,7 +727,7 @@ void QKmsDevice::createScreens() if (!m_screenConfig->separateScreens()) { // enable the virtual desktop - for (int i = 0; i < siblings.count(); ++i) + for (int i = 0; i < siblings.size(); ++i) registerScreen(siblings[i], i == primarySiblingIdx, virtualPositions[i], siblings); } } diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp index 3e67050589..19cdef5dd9 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(); @@ -139,7 +139,7 @@ void QTuioHandler::processPackets() for (const QOscMessage &message : qAsConst(messages)) { if (message.addressPattern() == "/tuio/2Dcur") { QList<QVariant> arguments = message.arguments(); - if (arguments.count() == 0) { + if (arguments.size() == 0) { qCWarning(lcTuioHandler, "Ignoring TUIO message with no arguments"); continue; } @@ -159,7 +159,7 @@ void QTuioHandler::processPackets() } } else if (message.addressPattern() == "/tuio/2Dobj") { QList<QVariant> arguments = message.arguments(); - if (arguments.count() == 0) { + if (arguments.size() == 0) { qCWarning(lcTuioHandler, "Ignoring TUIO message with no arguments"); continue; } @@ -188,8 +188,8 @@ void QTuioHandler::processPackets() void QTuioHandler::process2DCurSource(const QOscMessage &message) { QList<QVariant> arguments = message.arguments(); - if (arguments.count() != 2) { - qCWarning(lcTuioSource) << "Ignoring malformed TUIO source message: " << arguments.count(); + if (arguments.size() != 2) { + qCWarning(lcTuioSource) << "Ignoring malformed TUIO source message: " << arguments.size(); return; } @@ -214,7 +214,7 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message) QMap<int, QTuioCursor> oldActiveCursors = m_activeCursors; QMap<int, QTuioCursor> newActiveCursors; - for (int i = 1; i < arguments.count(); ++i) { + for (int i = 1; i < arguments.size(); ++i) { if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) { qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')'; return; @@ -255,8 +255,8 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message) void QTuioHandler::process2DCurSet(const QOscMessage &message) { QList<QVariant> arguments = message.arguments(); - if (arguments.count() < 7) { - qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count(); + if (arguments.size() < 7) { + qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.size(); return; } @@ -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) @@ -353,8 +353,8 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message) void QTuioHandler::process2DObjSource(const QOscMessage &message) { QList<QVariant> arguments = message.arguments(); - if (arguments.count() != 2) { - qCWarning(lcTuioSource, ) << "Ignoring malformed TUIO source message: " << arguments.count(); + if (arguments.size() != 2) { + qCWarning(lcTuioSource ) << "Ignoring malformed TUIO source message: " << arguments.size(); return; } @@ -379,7 +379,7 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message) QMap<int, QTuioToken> oldActiveTokens = m_activeTokens; QMap<int, QTuioToken> newActiveTokens; - for (int i = 1; i < arguments.count(); ++i) { + for (int i = 1; i < arguments.size(); ++i) { if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) { qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')'; return; @@ -420,8 +420,8 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message) void QTuioHandler::process2DObjSet(const QOscMessage &message) { QList<QVariant> arguments = message.arguments(); - if (arguments.count() < 7) { - qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count(); + if (arguments.size() < 7) { + qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.size(); return; } @@ -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/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index add6b64855..8ad4ff7510 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -1146,9 +1146,9 @@ QVariant QGifHandler::option(ImageOption option) const } // before the first frame is read, or we have an empty data stream if (frameNumber == -1) - return (imageSizes.count() > 0) ? QVariant(imageSizes.at(0)) : QVariant(); + return (imageSizes.size() > 0) ? QVariant(imageSizes.at(0)) : QVariant(); // after the last frame has been read, the next size is undefined - if (frameNumber >= imageSizes.count() - 1) + if (frameNumber >= imageSizes.size() - 1) return QVariant(); // and the last case: the size of the next frame return imageSizes.at(frameNumber + 1); @@ -1175,7 +1175,7 @@ int QGifHandler::imageCount() const QGIFFormat::scan(device(), &imageSizes, &loopCnt); scanIsCached = true; } - return imageSizes.count(); + return imageSizes.size(); } int QGifHandler::loopCount() const diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 496e927919..3bcf30bfc6 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -565,14 +565,14 @@ bool ICOReader::write(QIODevice *device, const QList<QImage> &images) { bool retValue = false; - if (images.count()) { + if (images.size()) { qint64 origOffset = device->pos(); ICONDIR id; id.idReserved = 0; id.idType = 1; - id.idCount = images.count(); + id.idCount = images.size(); ICONDIRENTRY * entries = new ICONDIRENTRY[id.idCount]; BMP_INFOHDR * bmpHeaders = new BMP_INFOHDR[id.idCount]; diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index eebc5940ce..6472702fdd 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -458,7 +458,7 @@ static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QSt if (!comment.isEmpty()) comment += ": "; comment += it.value().toUtf8(); - if (comment.length() > maxMarkerSize) + if (comment.size() > maxMarkerSize) comment.truncate(maxMarkerSize); jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)comment.constData(), comment.size()); } diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp index a6345f693d..72c4a47dbb 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp @@ -121,7 +121,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) return; // First window is always fullscreen. - if (windows.count() == 1) { + if (windows.size() == 1) { QWindow *window = windows[0]->sourceWindow(); if (platformIntegration->pointerWindow() != window) { platformIntegration->setPointerWindow(window); @@ -131,7 +131,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) } QWindow *enter = nullptr, *leave = nullptr; - for (int i = windows.count() - 1; i >= 0; --i) { + for (int i = windows.size() - 1; i >= 0; --i) { QWindow *window = windows[i]->sourceWindow(); const QRect geom = window->geometry(); if (geom.contains(pos)) { diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index 39c5b3d4bf..bbd0b8ed68 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -260,7 +260,7 @@ void QEglFSWindow::lower() #ifndef QT_NO_OPENGL QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); QList<QOpenGLCompositorWindow *> windows = compositor->windows(); - if (window()->type() != Qt::Desktop && windows.count() > 1) { + if (window()->type() != Qt::Desktop && windows.size() > 1) { int idx = windows.indexOf(this); if (idx > 0) { compositor->changeWindowIndex(this, idx - 1); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index 3a79ebb7b4..9ada2de2b6 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -168,7 +168,7 @@ void QEglFSKmsEglDeviceWindow::resetSurface() QByteArray reqLayerIndex = qgetenv("QT_QPA_EGLFS_LAYER_INDEX"); if (!reqLayerIndex.isEmpty()) { int idx = reqLayerIndex.toInt(); - if (idx >= 0 && idx < layers.count()) { + if (idx >= 0 && idx < layers.size()) { qCDebug(qLcEglfsKmsDebug, "EGLOutput layer index override = %d", idx); layer = layers[idx]; } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp index eadb079f70..d4e5f2f90c 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -18,7 +18,7 @@ QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, cons QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen() { - const int remainingScreenCount = qGuiApp->screens().count(); + const int remainingScreenCount = qGuiApp->screens().size(); qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount); if (!remainingScreenCount && !device()->screenConfig()->separateScreens()) static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 39ec35df9e..b2d1c17d5f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -115,7 +115,7 @@ QSize QEglFSX11Integration::screenSize() const { if (m_screenSize.isEmpty()) { QList<QByteArray> env = qgetenv("EGLFS_X11_SIZE").split('x'); - if (env.length() == 2) { + if (env.size() == 2) { m_screenSize = QSize(env.at(0).toInt(), env.at(1).toInt()); } else { XWindowAttributes a; diff --git a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp index beb8349635..a10cf47958 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp @@ -62,7 +62,7 @@ public: void swapBuffers(Output *output); - int outputCount() const { return m_outputs.count(); } + int outputCount() const { return m_outputs.size(); } Output *output(int idx) { return &m_outputs[idx]; } private: diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index cb02205601..2731ecfd8e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -145,7 +145,7 @@ std::optional<QJsonObject> QOffscreenIntegration::resolveConfigFileConfiguration QString configPrefix("configfile="_L1); if (param.startsWith(configPrefix)) { hasConfigFile = true; - configFilePath = param.mid(configPrefix.length()); + configFilePath = param.mid(configPrefix.size()); } } if (!hasConfigFile) diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index 60aae51100..ee68bee6e3 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -583,7 +583,7 @@ void QVncClientCursor::addClient(QVncClient *client) uint QVncClientCursor::removeClient(QVncClient *client) { clients.removeOne(client); - return clients.count(); + return clients.size(); } #endif // QT_CONFIG(cursor) diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 5992ebd74e..103bb1e22b 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -242,9 +242,9 @@ QGLXContext::QGLXContext(Display *display, QXcbScreen *screen, const QSurfaceFor // Robustness must match that of the shared context. if (share && share->format().testOption(QSurfaceFormat::ResetNotification)) m_format.setOption(QSurfaceFormat::ResetNotification); - Q_ASSERT(glVersions.count() > 0); + Q_ASSERT(glVersions.size() > 0); - for (int i = 0; !m_context && i < glVersions.count(); i++) { + for (int i = 0; !m_context && i < glVersions.size(); i++) { const int version = glVersions[i]; if (version > requestedVersion) continue; 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/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 3fdc43a11d..4611b43fdd 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -790,7 +790,7 @@ void QXcbConnection::setStartupId(const QByteArray &nextId) atom(QXcbAtom::_NET_STARTUP_ID), atom(QXcbAtom::UTF8_STRING), 8, - nextId.length(), + nextId.size(), nextId.constData()); else xcb_delete_property(xcb_connection(), clientLeader(), atom(QXcbAtom::_NET_STARTUP_ID)); @@ -939,7 +939,7 @@ xcb_window_t QXcbConnection::clientLeader() atom(QXcbAtom::SM_CLIENT_ID), XCB_ATOM_STRING, 8, - session.length(), + session.size(), session.constData()); } #endif diff --git a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp index dc7b5fc632..64ae27647c 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp @@ -219,7 +219,7 @@ QXcbScreen *QXcbConnection::createScreen(QXcbVirtualDesktop *virtualDesktop, void QXcbConnection::destroyScreen(QXcbScreen *screen) { QXcbVirtualDesktop *virtualDesktop = screen->virtualDesktop(); - if (virtualDesktop->screens().count() == 1) { + if (virtualDesktop->screens().size() == 1) { // If there are no other screens on the same virtual desktop, // then transform the physical screen into a fake screen. const QString nameWas = screen->name(); diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f528e8b593..6f732b57a0 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -226,7 +226,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, auto *deviceInfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info); if (removeExisting) { #if QT_CONFIG(tabletevent) - for (int i = 0; i < m_tabletData.count(); ++i) { + for (int i = 0; i < m_tabletData.size(); ++i) { if (m_tabletData.at(i).deviceId == deviceInfo->deviceid) { m_tabletData.remove(i); break; @@ -1627,7 +1627,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id) { - for (int i = 0; i < m_tabletData.count(); ++i) { + for (int i = 0; i < m_tabletData.size(); ++i) { if (m_tabletData.at(i).deviceId == id) return &m_tabletData[i]; } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index f10ae874ca..3dc52c9f06 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -614,7 +614,7 @@ void QXcbDrag::stopListeningForActionListChanges() int QXcbDrag::findTransactionByWindow(xcb_window_t window) { int at = -1; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.target == window || t.proxy_target == window) { at = i; @@ -627,7 +627,7 @@ int QXcbDrag::findTransactionByWindow(xcb_window_t window) int QXcbDrag::findTransactionByTime(xcb_timestamp_t timestamp) { int at = -1; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.timestamp == timestamp) { at = i; @@ -720,7 +720,7 @@ void QXcbDrag::handleEnter(QPlatformWindow *, const xcb_client_message_event_t * xdnd_types.append(event->data.data32[i]); } } - for(int i = 0; i < xdnd_types.length(); ++i) + for(int i = 0; i < xdnd_types.size(); ++i) qCDebug(lcQpaXDnd) << " " << connection()->atomName(xdnd_types.at(i)); } @@ -1089,7 +1089,7 @@ void QXcbDrag::timerEvent(QTimerEvent* e) { if (e->timerId() == cleanup_timer) { bool stopTimer = true; - for (int i = 0; i < transactions.count(); ++i) { + for (int i = 0; i < transactions.size(); ++i) { const Transaction &t = transactions.at(i); if (t.targetWindow) { // dnd within the same process, don't delete, these are taken care of diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7161af279c..9df9dd2bd9 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -80,7 +80,7 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa && connection->atomName(a) == "text/x-moz-url") { const QString mozUri = QLatin1StringView(data->split('\n').constFirst()) + u'\n'; *data = QByteArray(reinterpret_cast<const char *>(mozUri.data()), - mozUri.length() * 2); + mozUri.size() * 2); } else if (atomName == "application/x-color"_L1) *dataFormat = 16; ret = true; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 95802503a9..30746148bc 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -556,11 +556,11 @@ void QXcbScreen::updateColorSpaceAndEdid() m_edid.greenChromaticity, m_edid.blueChromaticity, QColorSpace::TransferFunction::Gamma, m_edid.gamma); } else { - if (m_edid.tables.length() == 1) { + if (m_edid.tables.size() == 1) { m_colorSpace = QColorSpace(m_edid.whiteChromaticity, m_edid.redChromaticity, m_edid.greenChromaticity, m_edid.blueChromaticity, m_edid.tables[0]); - } else if (m_edid.tables.length() == 3) { + } else if (m_edid.tables.size() == 3) { m_colorSpace = QColorSpace(m_edid.whiteChromaticity, m_edid.redChromaticity, m_edid.greenChromaticity, m_edid.blueChromaticity, m_edid.tables[0], m_edid.tables[1], m_edid.tables[2]); @@ -821,7 +821,7 @@ void QXcbScreen::sendStartupMessage(const QByteArray &message) const ev.sequence = 0; ev.window = rootWindow; int sent = 0; - int length = message.length() + 1; // include NUL byte + int length = message.size() + 1; // include NUL byte const char *data = message.constData(); do { if (sent == 20) @@ -839,7 +839,7 @@ void QXcbScreen::sendStartupMessage(const QByteArray &message) const QRect QXcbScreen::availableGeometry() const { static bool enforceNetWorkarea = !qEnvironmentVariableIsEmpty("QT_RELY_ON_NET_WORKAREA_ATOM"); - bool isMultiHeadSystem = virtualSiblings().length() > 1; + bool isMultiHeadSystem = virtualSiblings().size() > 1; bool useScreenGeometry = isMultiHeadSystem && !enforceNetWorkarea; return useScreenGeometry ? m_geometry : m_availableGeometry; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index ec305d5030..b4e28ab831 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -101,19 +101,19 @@ static void sm_setProperty(const QString &name, const QString &value) { QByteArray v = value.toUtf8(); SmPropValue prop; - prop.length = v.length(); + prop.length = v.size(); prop.value = (SmPointer) const_cast<char *>(v.constData()); sm_setProperty(name.toLatin1().data(), SmARRAY8, 1, &prop); } 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()); for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) { - prop[count].length = (*it).length(); + prop[count].length = (*it).size(); vl.append((*it).toUtf8()); prop[count].value = (char*)vl.constLast().data(); ++count; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index a37c03cc60..363ea29d14 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -166,7 +166,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) tp.value = (uchar*)qcs.data(); tp.encoding = XA_STRING; tp.format = 8; - tp.nitems = qcs.length(); + tp.nitems = qcs.size(); free_prop = false; } return &tp; @@ -1079,7 +1079,7 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow() } else { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32, - atoms.count(), atoms.constData()); + atoms.size(), atoms.constData()); } xcb_flush(xcb_connection()); } @@ -1263,7 +1263,7 @@ void QXcbWindow::setWindowIconText(const QString &title) atom(QXcbAtom::_NET_WM_ICON_NAME), atom(QXcbAtom::UTF8_STRING), 8, - ba.length(), + ba.size(), ba.constData()); } @@ -1575,7 +1575,7 @@ void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags) } else { xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, - atoms.count(), atoms.constData()); + atoms.size(), atoms.constData()); } xcb_flush(xcb_connection()); } @@ -2547,7 +2547,7 @@ void QXcbWindow::setWindowTitle(const QXcbConnection *conn, xcb_window_t window, conn->atom(QXcbAtom::_NET_WM_NAME), conn->atom(QXcbAtom::UTF8_STRING), 8, - ba.length(), + ba.size(), ba.constData()); #if QT_CONFIG(xcb_xlib) diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 62fd13e5b9..21828922c6 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -104,7 +104,7 @@ public: void populateSettings(const QByteArray &xSettings) { - if (xSettings.length() < 12) + if (xSettings.size() < 12) return; char byteOrder = xSettings.at(0); if (byteOrder != XCB_IMAGE_ORDER_LSB_FIRST && byteOrder != XCB_IMAGE_ORDER_MSB_FIRST) { @@ -192,7 +192,7 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen) auto atom_reply = Q_XCB_REPLY(xcb_intern_atom, screen->xcb_connection(), true, - settings_atom_for_screen.length(), + settings_atom_for_screen.size(), settings_atom_for_screen.constData()); if (!atom_reply) return; diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp index 5589ff8836..c4ea0e5e33 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp @@ -123,13 +123,13 @@ static QString convertMnemonics(QString text, bool *found) { *found = false; - qsizetype i = text.length() - 1; + qsizetype i = text.size() - 1; while (i >= 0) { const QChar c = text.at(i); if (c == u'&') { if (i == 0 || text.at(i - 1) != u'&') { // convert Qt to GTK mnemonic - if (i < text.length() - 1 && !text.at(i + 1).isSpace()) { + if (i < text.size() - 1 && !text.at(i + 1).isSpace()) { text.replace(i, 1, u'_'); *found = true; } @@ -329,7 +329,7 @@ void QGtk3Menu::insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *befor GtkWidget *handle = gitem->create(); int index = m_items.indexOf(static_cast<QGtk3MenuItem *>(before)); if (index < 0) - index = m_items.count(); + index = m_items.size(); m_items.insert(index, gitem); gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), handle, index); } 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/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 450d551ac5..7859f78938 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -80,7 +80,7 @@ static inline QVariant qDateTimeFromString(QString &val) #else if (val.isEmpty()) return QVariant(QDateTime()); - if (val.length() == 14) + if (val.size() == 14) // TIMESTAMPS have the format yyyyMMddhhmmss val.insert(4, u'-').insert(7, u'-').insert(10, u'T').insert(13, u':').insert(16, u':'); return QVariant(QDateTime::fromString(val, Qt::ISODate)); @@ -286,7 +286,7 @@ static bool qIsInteger(int t) void QMYSQLResultPrivate::bindBlobs() { - for (int i = 0; i < fields.count(); ++i) { + for (int i = 0; i < fields.size(); ++i) { const MYSQL_FIELD *fieldInfo = fields.at(i).myField; if (qIsBlob(inBinds[i].buffer_type) && meta && fieldInfo) { MYSQL_BIND *bind = &inBinds[i]; @@ -392,7 +392,7 @@ void QMYSQLResult::cleanup() } int i; - for (i = 0; i < d->fields.count(); ++i) + for (i = 0; i < d->fields.size(); ++i) delete[] d->fields[i].outField; if (d->outBinds) { @@ -509,7 +509,7 @@ bool QMYSQLResult::fetchFirst() QVariant QMYSQLResult::data(int field) { Q_D(QMYSQLResult); - if (!isSelect() || field >= d->fields.count()) { + if (!isSelect() || field >= d->fields.size()) { qWarning("QMYSQLResult::data: column %d out of range", field); return QVariant(); } @@ -625,7 +625,7 @@ QVariant QMYSQLResult::data(int field) bool QMYSQLResult::isNull(int field) { Q_D(const QMYSQLResult); - if (field < 0 || field >= d->fields.count()) + if (field < 0 || field >= d->fields.size()) return true; if (d->preparedQuery) return d->fields.at(field).nullIndicator; @@ -644,7 +644,7 @@ bool QMYSQLResult::reset (const QString& query) cleanup(); const QByteArray encQuery = query.toUtf8(); - if (mysql_real_query(d->drv_d_func()->mysql, encQuery.data(), encQuery.length())) { + if (mysql_real_query(d->drv_d_func()->mysql, encQuery.data(), encQuery.size())) { setLastError(qMakeError(QCoreApplication::translate("QMYSQLResult", "Unable to execute query"), QSqlError::StatementError, d->drv_d_func())); return false; @@ -752,7 +752,7 @@ bool QMYSQLResult::nextResult() d->result = 0; setSelect(false); - for (int i = 0; i < d->fields.count(); ++i) + for (int i = 0; i < d->fields.size(); ++i) delete[] d->fields[i].outField; d->fields.clear(); @@ -840,7 +840,7 @@ bool QMYSQLResult::prepare(const QString& query) } const QByteArray encQuery = query.toUtf8(); - r = mysql_stmt_prepare(d->stmt, encQuery.constData(), encQuery.length()); + r = mysql_stmt_prepare(d->stmt, encQuery.constData(), encQuery.size()); if (r != 0) { setLastError(qMakeStmtError(QCoreApplication::translate("QMYSQLResult", "Unable to prepare statement"), QSqlError::StatementError, d->stmt)); @@ -882,10 +882,10 @@ bool QMYSQLResult::exec() } if (mysql_stmt_param_count(d->stmt) > 0 && - mysql_stmt_param_count(d->stmt) == (uint)values.count()) { + mysql_stmt_param_count(d->stmt) == (uint)values.size()) { - nullVector.resize(values.count()); - for (int i = 0; i < values.count(); ++i) { + nullVector.resize(values.size()); + for (int i = 0; i < values.size(); ++i) { const QVariant &val = boundValues().at(i); void *data = const_cast<void *>(val.constData()); @@ -960,7 +960,7 @@ bool QMYSQLResult::exec() stringVector.append(ba); currBind->buffer_type = MYSQL_TYPE_STRING; currBind->buffer = const_cast<char *>(ba.constData()); - currBind->buffer_length = ba.length(); + currBind->buffer_length = ba.size(); break; } } } @@ -1178,7 +1178,7 @@ bool QMYSQLDriver::open(const QString& db, uint writeTimeout = 0; // extract the real options from the string - for (int i = 0; i < opts.count(); ++i) { + for (int i = 0; i < opts.size(); ++i) { QString tmp(opts.at(i).simplified()); qsizetype idx; if ((idx = tmp.indexOf(u'=')) != -1) { diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index 51a3908867..cfa6db67ab 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -223,7 +223,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i // already fetched Q_ASSERT(!initialFetch); skipRow = false; - for(int i=0;i<firstRow.count();i++) + for(int i=0;i<firstRow.size();i++) values[i]=firstRow[i]; return skippedStatus; } @@ -382,10 +382,10 @@ bool QSQLiteResult::execBatch(bool arrayBind) Q_D(QSqlResult); QScopedValueRollback<QList<QVariant>> valuesScope(d->values); QList<QVariant> values = d->values; - if (values.count() == 0) + if (values.size() == 0) return false; - for (int i = 0; i < values.at(0).toList().count(); ++i) { + for (int i = 0; i < values.at(0).toList().size(); ++i) { d->values.clear(); QScopedValueRollback<QHash<QString, QList<int>>> indexesScope(d->indexes); auto it = d->indexes.constBegin(); @@ -419,16 +419,16 @@ bool QSQLiteResult::exec() } int paramCount = sqlite3_bind_parameter_count(d->stmt); - bool paramCountIsValid = paramCount == values.count(); + bool paramCountIsValid = paramCount == values.size(); #if (SQLITE_VERSION_NUMBER >= 3003011) // In the case of the reuse of a named placeholder // We need to check explicitly that paramCount is greater than or equal to 1, as sqlite // can end up in a case where for virtual tables it returns 0 even though it // has parameters - if (paramCount >= 1 && paramCount < values.count()) { + if (paramCount >= 1 && paramCount < values.size()) { const auto countIndexes = [](int counter, const QList<int> &indexList) { - return counter + indexList.length(); + return counter + indexList.size(); }; const int bindParamCount = std::accumulate(d->indexes.cbegin(), @@ -436,7 +436,7 @@ bool QSQLiteResult::exec() 0, countIndexes); - paramCountIsValid = bindParamCount == values.count(); + paramCountIsValid = bindParamCount == values.size(); // When using named placeholders, it will reuse the index for duplicated // placeholders. So we need to ensure the QList has only one instance of // each value as SQLite will do the rest for us. @@ -779,7 +779,7 @@ void QSQLiteDriver::close() for (QSQLiteResult *result : qAsConst(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; diff --git a/src/plugins/tls/openssl/qdtls_openssl.cpp b/src/plugins/tls/openssl/qdtls_openssl.cpp index fe8cbf23e0..0cb4d0b831 100644 --- a/src/plugins/tls/openssl/qdtls_openssl.cpp +++ b/src/plugins/tls/openssl/qdtls_openssl.cpp @@ -1252,12 +1252,12 @@ unsigned QDtlsPrivateOpenSSL::pskClientCallback(const char *hint, char *identity return 0; // Copy data back into OpenSSL - const int identityLength = qMin(pskAuthenticator.identity().length(), + const int identityLength = qMin(pskAuthenticator.identity().size(), pskAuthenticator.maximumIdentityLength()); std::memcpy(identity, pskAuthenticator.identity().constData(), identityLength); identity[identityLength] = 0; - const int pskLength = qMin(pskAuthenticator.preSharedKey().length(), + const int pskLength = qMin(pskAuthenticator.preSharedKey().size(), pskAuthenticator.maximumPreSharedKeyLength()); std::memcpy(psk, pskAuthenticator.preSharedKey().constData(), pskLength); @@ -1283,7 +1283,7 @@ unsigned QDtlsPrivateOpenSSL::pskServerCallback(const char *identity, unsigned c return 0; // Copy data back into OpenSSL - const int pskLength = qMin(pskAuthenticator.preSharedKey().length(), + const int pskLength = qMin(pskAuthenticator.preSharedKey().size(), pskAuthenticator.maximumPreSharedKeyLength()); std::memcpy(psk, pskAuthenticator.preSharedKey().constData(), pskLength); diff --git a/src/plugins/tls/openssl/qsslcontext_openssl.cpp b/src/plugins/tls/openssl/qsslcontext_openssl.cpp index 33f0d41a09..e2b89d8805 100644 --- a/src/plugins/tls/openssl/qsslcontext_openssl.cpp +++ b/src/plugins/tls/openssl/qsslcontext_openssl.cpp @@ -218,7 +218,7 @@ SSL* QSslContext::createSsl() QList<QByteArray> protocols = sslConfiguration.d.constData()->nextAllowedProtocols; if (!protocols.isEmpty()) { m_supportedNPNVersions.clear(); - for (int a = 0; a < protocols.count(); ++a) { + for (int a = 0; a < protocols.size(); ++a) { if (protocols.at(a).size() > 255) { qCWarning(lcTlsBackend) << "TLS NPN extension" << protocols.at(a) << "is too long and will be ignored."; @@ -230,7 +230,7 @@ SSL* QSslContext::createSsl() } if (m_supportedNPNVersions.size()) { m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data()); - m_npnContext.len = m_supportedNPNVersions.length(); + m_npnContext.len = m_supportedNPNVersions.size(); m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone; // Callback's type has a parameter 'const unsigned char ** out' // since it was introduced in 1.0.2. Internally, OpenSSL's own code @@ -702,7 +702,7 @@ QT_WARNING_POP const QByteArray ¶ms = dhparams.d->derData; const char *ptr = params.constData(); DH *dh = q_d2i_DHparams(nullptr, reinterpret_cast<const unsigned char **>(&ptr), - params.length()); + params.size()); if (dh == nullptr) qFatal("q_d2i_DHparams failed to convert QSslDiffieHellmanParameters to DER form"); q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh); diff --git a/src/plugins/tls/openssl/qsslsocket_openssl_symbols.cpp b/src/plugins/tls/openssl/qsslsocket_openssl_symbols.cpp index cb15bf2bce..feed08bd77 100644 --- a/src/plugins/tls/openssl/qsslsocket_openssl_symbols.cpp +++ b/src/plugins/tls/openssl/qsslsocket_openssl_symbols.cpp @@ -551,7 +551,7 @@ struct LibGreaterThan { const auto lhsparts = lhs.split(u'.'); const auto rhsparts = rhs.split(u'.'); - Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1); + Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1); // note: checking rhs < lhs, the same as lhs > rhs return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(), diff --git a/src/plugins/tls/openssl/qtls_openssl.cpp b/src/plugins/tls/openssl/qtls_openssl.cpp index 27abf1bc8d..a78bdca53f 100644 --- a/src/plugins/tls/openssl/qtls_openssl.cpp +++ b/src/plugins/tls/openssl/qtls_openssl.cpp @@ -1726,11 +1726,11 @@ unsigned TlsCryptographOpenSSL::pskClientTlsCallback(const char *hint, char *ide return 0; // Copy data back into OpenSSL - const int identityLength = qMin(authenticator.identity().length(), authenticator.maximumIdentityLength()); + const int identityLength = qMin(authenticator.identity().size(), authenticator.maximumIdentityLength()); std::memcpy(identity, authenticator.identity().constData(), identityLength); identity[identityLength] = 0; - const int pskLength = qMin(authenticator.preSharedKey().length(), authenticator.maximumPreSharedKeyLength()); + const int pskLength = qMin(authenticator.preSharedKey().size(), authenticator.maximumPreSharedKeyLength()); std::memcpy(psk, authenticator.preSharedKey().constData(), pskLength); return pskLength; } @@ -1752,7 +1752,7 @@ unsigned TlsCryptographOpenSSL::pskServerTlsCallback(const char *identity, unsig return 0; // Copy data back into OpenSSL - const int pskLength = qMin(authenticator.preSharedKey().length(), authenticator.maximumPreSharedKeyLength()); + const int pskLength = qMin(authenticator.preSharedKey().size(), authenticator.maximumPreSharedKeyLength()); std::memcpy(psk, authenticator.preSharedKey().constData(), pskLength); return pskLength; } diff --git a/src/plugins/tls/openssl/qtlskey_openssl.cpp b/src/plugins/tls/openssl/qtlskey_openssl.cpp index b17e1d9d74..8f54fda7fa 100644 --- a/src/plugins/tls/openssl/qtlskey_openssl.cpp +++ b/src/plugins/tls/openssl/qtlskey_openssl.cpp @@ -101,19 +101,19 @@ QByteArray TlsKeyOpenSSL::derFromPem(const QByteArray &pem, QMap<QByteArray, QBy QByteArray der(pem); int headerIndex = der.indexOf(header); - int footerIndex = der.indexOf(footer, headerIndex + header.length()); + int footerIndex = der.indexOf(footer, headerIndex + header.size()); if (type() != QSsl::PublicKey) { if (headerIndex == -1 || footerIndex == -1) { header = pkcs8Header(true); footer = pkcs8Footer(true); headerIndex = der.indexOf(header); - footerIndex = der.indexOf(footer, headerIndex + header.length()); + footerIndex = der.indexOf(footer, headerIndex + header.size()); } if (headerIndex == -1 || footerIndex == -1) { header = pkcs8Header(false); footer = pkcs8Footer(false); headerIndex = der.indexOf(header); - footerIndex = der.indexOf(footer, headerIndex + header.length()); + footerIndex = der.indexOf(footer, headerIndex + header.size()); } } if (headerIndex == -1 || footerIndex == -1) @@ -124,7 +124,7 @@ QByteArray TlsKeyOpenSSL::derFromPem(const QByteArray &pem, QMap<QByteArray, QBy if (der.contains("Proc-Type:")) { // taken from QHttpNetworkReplyPrivate::parseHeader int i = 0; - while (i < der.length()) { + while (i < der.size()) { int j = der.indexOf(':', i); // field-name if (j == -1) break; @@ -143,7 +143,7 @@ QByteArray TlsKeyOpenSSL::derFromPem(const QByteArray &pem, QMap<QByteArray, QBy int length = i -(hasCR ? 1: 0) - j; value += der.mid(j, length).trimmed(); j = ++i; - } while (i < der.length() && (der.at(i) == ' ' || der.at(i) == '\t')); + } while (i < der.size() && (der.at(i) == ' ' || der.at(i) == '\t')); if (i == -1) break; // something is wrong diff --git a/src/plugins/tls/openssl/qx509_openssl.cpp b/src/plugins/tls/openssl/qx509_openssl.cpp index 29f98755bd..0d911d086d 100644 --- a/src/plugins/tls/openssl/qx509_openssl.cpp +++ b/src/plugins/tls/openssl/qx509_openssl.cpp @@ -616,7 +616,7 @@ QList<QSslError> X509CertificateOpenSSL::verify(const QList<QSslCertificate> &ca const QString &hostName) { // This was previously QSslSocketPrivate::verify(). - if (certificateChain.count() <= 0) + if (certificateChain.size() <= 0) return {QSslError(QSslError::UnspecifiedError)}; QList<QSslError> errors; @@ -658,7 +658,7 @@ QList<QSslError> X509CertificateOpenSSL::verify(const QList<QSslCertificate> &ca // Build the chain of intermediate certificates STACK_OF(X509) *intermediates = nullptr; - if (certificateChain.length() > 1) { + if (certificateChain.size() > 1) { intermediates = (STACK_OF(X509) *) q_OPENSSL_sk_new_null(); if (!intermediates) { diff --git a/src/plugins/tls/shared/qx509_generic.cpp b/src/plugins/tls/shared/qx509_generic.cpp index cfe2786680..e700552c43 100644 --- a/src/plugins/tls/shared/qx509_generic.cpp +++ b/src/plugins/tls/shared/qx509_generic.cpp @@ -188,7 +188,7 @@ bool X509CertificateGeneric::parse(const QByteArray &data) if (!elem.read(certStream) || elem.type() != QAsn1Element::SequenceType) return false; - QByteArray issuerDer = data.mid(dataStream.device()->pos() - elem.value().length(), elem.value().length()); + QByteArray issuerDer = data.mid(dataStream.device()->pos() - elem.value().size(), elem.value().size()); issuerInfoEntries = elem.toInfo(); // validity period @@ -215,7 +215,7 @@ bool X509CertificateGeneric::parse(const QByteArray &data) if (!elem.read(certStream) || elem.type() != QAsn1Element::SequenceType) return false; - QByteArray subjectDer = data.mid(dataStream.device()->pos() - elem.value().length(), elem.value().length()); + QByteArray subjectDer = data.mid(dataStream.device()->pos() - elem.value().size(), elem.value().size()); subjectInfoEntries = elem.toInfo(); subjectMatchesIssuer = issuerDer == subjectDer; @@ -285,7 +285,7 @@ bool X509CertificateGeneric::parse(const QByteArray &data) case QAsn1Element::IpAddressType: { QHostAddress ipAddress; QByteArray ipAddrValue = nameElem.value(); - switch (ipAddrValue.length()) { + switch (ipAddrValue.size()) { case 4: // IPv4 ipAddress = QHostAddress(qFromBigEndian(*reinterpret_cast<quint32 *>(ipAddrValue.data()))); break; diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index b1d5d8c38f..b58ff76d49 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -61,7 +61,7 @@ public: { bool replacePercent = false; if (input.endsWith(u'%')) { - input = input.left(input.length() - 1); + input = input.left(input.size() - 1); replacePercent = true; } State state = QDoubleValidator::validate(input, pos); @@ -450,7 +450,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel() Q_Q(QPrintPreviewDialog); int numPages = preview->pageCount(); - int maxChars = QString::number(numPages).length(); + int maxChars = QString::number(numPages).size(); pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages)); int cyphersWidth = q->fontMetrics().horizontalAdvance(QString().fill(u'8', maxChars)); int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth; diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 5d1d4e5c98..080eca70ca 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -198,7 +198,7 @@ QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets) JobSheets result; const QStringList parts = jobSheets.split(u','); - if (parts.count() == 2) { + if (parts.size() == 2) { result.startBannerPage = stringToBannerPage(parts[0]); result.endBannerPage = stringToBannerPage(parts[1]); } diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index 0334f7a27c..4c34457570 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -401,9 +401,9 @@ void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect) bool QAlphaPaintEnginePrivate::canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const { if (somethingInRectHasAlpha) { - if (m_dirtyRects.count() != m_numberOfCachedRects) { - m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.count()); - m_numberOfCachedRects = m_dirtyRects.count(); + if (m_dirtyRects.size() != m_numberOfCachedRects) { + m_cachedDirtyRgn.setRects(m_dirtyRects.constData(), m_dirtyRects.size()); + m_numberOfCachedRects = m_dirtyRects.size(); } return m_cachedDirtyRgn.intersects(rect.toAlignedRect()); } diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp index 1b82ad307e..247fbf9601 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.cpp +++ b/src/printsupport/widgets/qprintpreviewwidget.cpp @@ -182,7 +182,7 @@ void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting) { Q_Q(QPrintPreviewWidget); - if (curPage < 1 || curPage > pages.count()) + if (curPage < 1 || curPage > pages.size()) return; if (!doFitting && !fitting) @@ -314,7 +314,7 @@ void QPrintPreviewWidgetPrivate::populateScene() void QPrintPreviewWidgetPrivate::layoutPages() { - int numPages = pages.count(); + int numPages = pages.size(); if (numPages < 1) return; @@ -365,7 +365,7 @@ void QPrintPreviewWidgetPrivate::generatePreview() pictures = printer->d_func()->previewPages(); populateScene(); // i.e. setPreviewPrintedPictures() e.l. layoutPages(); - curPage = pages.count() > 0 ? qBound(1, curPage, pages.count()) : 1; + curPage = pages.size() > 0 ? qBound(1, curPage, pages.size()) : 1; if (fitting) _q_fit(); emit q->previewChanged(); @@ -373,13 +373,13 @@ void QPrintPreviewWidgetPrivate::generatePreview() void QPrintPreviewWidgetPrivate::setCurrentPage(int pageNumber) { - if (pageNumber < 1 || pageNumber > pages.count()) + if (pageNumber < 1 || pageNumber > pages.size()) return; int lastPage = curPage; curPage = pageNumber; - if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) { + if (lastPage != curPage && lastPage > 0 && lastPage <= pages.size()) { if (zoomMode != QPrintPreviewWidget::FitInView) { QScrollBar *hsc = graphicsView->horizontalScrollBar(); QScrollBar *vsc = graphicsView->verticalScrollBar(); diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index 997441ab49..7c8c329d64 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -516,7 +516,7 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName, s.clear(); } else { vals.chop(2); // remove trailing comma - s[s.length() - 2] = u')'; + s[s.size() - 2] = u')'; s.append("VALUES ("_L1).append(vals).append(u')'); } break; } @@ -598,7 +598,7 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const { QString result = field.value().toString(); if (trimStrings) { - int end = result.length(); + int end = result.size(); while (end && result.at(end-1).isSpace()) /* skip white space from end */ end--; result.truncate(end); diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp index 41fcd745cd..74f42b2e48 100644 --- a/src/sql/kernel/qsqlrecord.cpp +++ b/src/sql/kernel/qsqlrecord.cpp @@ -18,7 +18,7 @@ public: QSqlRecordPrivate(); QSqlRecordPrivate(const QSqlRecordPrivate &other); - inline bool contains(int index) { return index >= 0 && index < fields.count(); } + inline bool contains(int index) { return index >= 0 && index < fields.size(); } QString createField(int index, const QString &prefix) const; QList<QSqlField> fields; @@ -337,7 +337,7 @@ bool QSqlRecord::contains(const QString& name) const void QSqlRecord::clearValues() { detach(); - int count = d->fields.count(); + int count = d->fields.size(); for (int i = 0; i < count; ++i) d->fields[i].clear(); } @@ -451,7 +451,7 @@ bool QSqlRecord::isGenerated(int index) const int QSqlRecord::count() const { - return d->fields.count(); + return d->fields.size(); } /*! diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index b45f7b6790..642aea5461 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -630,7 +630,7 @@ bool QSqlResult::exec() int i; QVariant val; QString holder; - for (i = d->holders.count() - 1; i >= 0; --i) { + for (i = d->holders.size() - 1; i >= 0; --i) { holder = d->holders.at(i).holderName; val = d->values.value(d->indexes.value(holder).value(0,-1)); QSqlField f(""_L1, val.metaType()); @@ -639,13 +639,13 @@ bool QSqlResult::exec() else f.setValue(val); query = query.replace(d->holders.at(i).holderPos, - holder.length(), driver()->formatValue(f)); + holder.size(), driver()->formatValue(f)); } } else { QString val; qsizetype i = 0; int idx = 0; - for (idx = 0; idx < d->values.count(); ++idx) { + for (idx = 0; idx < d->values.size(); ++idx) { i = query.indexOf(u'?', i); if (i == -1) continue; @@ -657,7 +657,7 @@ bool QSqlResult::exec() f.setValue(var); val = driver()->formatValue(f); query = query.replace(i, 1, driver()->formatValue(f)); - i += val.length(); + i += val.size(); } } @@ -683,7 +683,7 @@ void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType param QList<int> &indexes = d->indexes[d->fieldSerial(index)]; if (!indexes.contains(index)) indexes.append(index); - if (d->values.count() <= index) + if (d->values.size() <= index) d->values.resize(index + 1); d->values[index] = val; if (paramType != QSql::In || !d->types.isEmpty()) @@ -709,7 +709,7 @@ void QSqlResult::bindValue(const QString& placeholder, const QVariant& val, // bindings - don't reset it const QList<int> indexes = d->indexes.value(placeholder); for (int idx : indexes) { - if (d->values.count() <= idx) + if (d->values.size() <= idx) d->values.resize(idx + 1); d->values[idx] = val; if (paramType != QSql::In || !d->types.isEmpty()) @@ -789,7 +789,7 @@ QSql::ParamType QSqlResult::bindValueType(const QString& placeholder) const int QSqlResult::boundValueCount() const { Q_D(const QSqlResult); - return d->values.count(); + return d->values.size(); } /*! @@ -949,10 +949,10 @@ bool QSqlResult::execBatch(bool arrayBind) Q_D(QSqlResult); QList<QVariant> values = d->values; - if (values.count() == 0) + if (values.size() == 0) return false; - for (int i = 0; i < values.at(0).toList().count(); ++i) { - for (int j = 0; j < values.count(); ++j) + for (int i = 0; i < values.at(0).toList().size(); ++i) { + for (int j = 0; j < values.size(); ++j) bindValue(j, values.at(j).toList().at(i), QSql::In); if (!exec()) return false; diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp index 61620f81d4..4572a4d305 100644 --- a/src/sql/models/qsqlquerymodel.cpp +++ b/src/sql/models/qsqlquerymodel.cpp @@ -628,7 +628,7 @@ bool QSqlQueryModel::insertColumns(int column, int count, const QModelIndex &par d->colOffsets.append(nVal); Q_ASSERT(d->colOffsets.size() >= d->rec.count()); } - for (int i = column + 1; i < d->colOffsets.count(); ++i) + for (int i = column + 1; i < d->colOffsets.size(); ++i) ++d->colOffsets[i]; } endInsertColumns(); @@ -657,7 +657,7 @@ bool QSqlQueryModel::removeColumns(int column, int count, const QModelIndex &par int i; for (i = 0; i < count; ++i) d->rec.remove(column); - for (i = column; i < d->colOffsets.count(); ++i) + for (i = column; i < d->colOffsets.size(); ++i) d->colOffsets[i] -= count; endRemoveColumns(); diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp index cb4c5df6c2..4a0d2fa9b3 100644 --- a/src/sql/models/qsqlrelationaltablemodel.cpp +++ b/src/sql/models/qsqlrelationaltablemodel.cpp @@ -253,7 +253,7 @@ public: void QSqlRelationalTableModelPrivate::clearChanges() { - for (int i = 0; i < relations.count(); ++i) { + for (int i = 0; i < relations.size(); ++i) { QRelation &rel = relations[i]; rel.clear(); } @@ -277,7 +277,7 @@ int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const void QSqlRelationalTableModelPrivate::clearCache() { - for (int i = 0; i < relations.count(); ++i) + for (int i = 0; i < relations.size(); ++i) relations[i].clearDictionary(); QSqlTableModelPrivate::clearCache(); @@ -395,7 +395,7 @@ QVariant QSqlRelationalTableModel::data(const QModelIndex &index, int role) cons { Q_D(const QSqlRelationalTableModel); - if (role == Qt::DisplayRole && index.column() >= 0 && index.column() < d->relations.count() && + if (role == Qt::DisplayRole && index.column() >= 0 && index.column() < d->relations.size() && d->relations.value(index.column()).isValid()) { QRelation &relation = d->relations[index.column()]; if (!relation.isDictionaryInitialized()) @@ -438,7 +438,7 @@ bool QSqlRelationalTableModel::setData(const QModelIndex &index, const QVariant int role) { Q_D(QSqlRelationalTableModel); - if ( role == Qt::EditRole && index.column() > 0 && index.column() < d->relations.count() + if ( role == Qt::EditRole && index.column() > 0 && index.column() < d->relations.size() && d->relations.value(index.column()).isValid()) { QRelation &relation = d->relations[index.column()]; if (!relation.isDictionaryInitialized()) @@ -603,7 +603,7 @@ QString QSqlRelationalTableModel::selectStatement() const QSqlTableModel *QSqlRelationalTableModel::relationModel(int column) const { Q_D(const QSqlRelationalTableModel); - if (column < 0 || column >= d->relations.count()) + if (column < 0 || column >= d->relations.size()) return nullptr; QRelation &relation = const_cast<QSqlRelationalTableModelPrivate *>(d)->relations[column]; @@ -749,7 +749,7 @@ bool QSqlRelationalTableModel::removeColumns(int column, int count, const QModel for (int i = 0; i < count; ++i) { d->baseRec.remove(column); - if (d->relations.count() > column) + if (d->relations.size() > column) d->relations.remove(column); } return QSqlTableModel::removeColumns(column, count, parent); diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 1fed690170..c46cc5aa6d 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -32,7 +32,7 @@ QSqlTableModelPrivate::~QSqlTableModelPrivate() QSqlRecord QSqlTableModelPrivate::record(const QList<QVariant> &values) const { QSqlRecord r = rec; - for (int i = 0; i < r.count() && i < values.count(); ++i) + for (int i = 0; i < r.count() && i < values.size(); ++i) r.setValue(i, values.at(i)); return r; } @@ -382,7 +382,7 @@ bool QSqlTableModel::selectRow(int row) false); static const QString wh = Sql::where() + Sql::sp(); if (d->filter.startsWith(wh, Qt::CaseInsensitive)) - d->filter.remove(0, wh.length()); + d->filter.remove(0, wh.size()); QString stmt; diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index 2add1acfca..eb52d28d59 100644 --- a/src/testlib/qabstractitemmodeltester.cpp +++ b/src/testlib/qabstractitemmodeltester.cpp @@ -867,7 +867,7 @@ void QAbstractItemModelTesterPrivate::layoutChanged() MODELTESTER_COMPARE(changeInFlight, ChangeInFlight::LayoutChanged); changeInFlight = ChangeInFlight::None; - for (int i = 0; i < changing.count(); ++i) { + for (int i = 0; i < changing.size(); ++i) { QPersistentModelIndex p = changing[i]; MODELTESTER_COMPARE(model->index(p.row(), p.column(), p.parent()), QModelIndex(p)); } diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e716c38a73..75443c96dc 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -120,10 +120,10 @@ namespace QTest { QString beforeDecimalPoint = QString::number(qint64(number), 'f', 0); QString afterDecimalPoint = QString::number(number, 'f', 20); - afterDecimalPoint.remove(0, beforeDecimalPoint.length() + 1); + afterDecimalPoint.remove(0, beforeDecimalPoint.size() + 1); - int beforeUse = qMin(beforeDecimalPoint.length(), significantDigits); - int beforeRemove = beforeDecimalPoint.length() - beforeUse; + int beforeUse = qMin(beforeDecimalPoint.size(), significantDigits); + int beforeRemove = beforeDecimalPoint.size() - beforeUse; // Replace insignificant digits before the decimal point with zeros. beforeDecimalPoint.chop(beforeRemove); @@ -138,21 +138,21 @@ namespace QTest { ++afterUse; int i = 0; - while (i < afterDecimalPoint.length() && afterDecimalPoint.at(i) == u'0') + while (i < afterDecimalPoint.size() && afterDecimalPoint.at(i) == u'0') ++i; afterUse += i; } - int afterRemove = afterDecimalPoint.length() - afterUse; + int afterRemove = afterDecimalPoint.size() - afterUse; afterDecimalPoint.chop(afterRemove); QChar separator = u','; QChar decimalPoint = u'.'; // insert thousands separators - int length = beforeDecimalPoint.length(); - for (int i = beforeDecimalPoint.length() -1; i >= 1; --i) { + int length = beforeDecimalPoint.size(); + for (int i = beforeDecimalPoint.size() -1; i >= 1; --i) { if ((length - i) % 3 == 0) beforeDecimalPoint.insert(i, separator); } @@ -172,7 +172,7 @@ namespace QTest { int formatResult(char * buffer, int bufferSize, T number, int significantDigits) { QString result = formatResult(number, significantDigits); - int size = result.length(); + int size = result.size(); qstrncpy(buffer, std::move(result).toLatin1().constData(), bufferSize); return size; } diff --git a/src/testlib/qpropertytesthelper_p.h b/src/testlib/qpropertytesthelper_p.h index b5bd8d2583..f2cb82cdd7 100644 --- a/src/testlib/qpropertytesthelper_p.h +++ b/src/testlib/qpropertytesthelper_p.h @@ -129,7 +129,7 @@ void testReadWritePropertyBasics( testedObj.property(propertyName).template value<PropertyType>(), initial, comparator, represent); if (spy) - QCOMPARE(spy->count(), 1); + QCOMPARE(spy->size(), 1); QUntypedBindable bindable = metaProperty.bindable(&instance); @@ -148,7 +148,7 @@ void testReadWritePropertyBasics( QPROPERTY_TEST_COMPARISON_HELPER(propObserver.value(), changed, comparator, represent); QPROPERTY_TEST_COMPARISON_HELPER(propObserverLambda.value(), changed, comparator, represent); if (spy) - QCOMPARE(spy->count(), 2); + QCOMPARE(spy->size(), 2); // Bind object's property to other property QProperty<PropertyType> propSetter(initial); @@ -162,7 +162,7 @@ void testReadWritePropertyBasics( QPROPERTY_TEST_COMPARISON_HELPER(propObserver.value(), initial, comparator, represent); QPROPERTY_TEST_COMPARISON_HELPER(propObserverLambda.value(), initial, comparator, represent); if (spy) - QCOMPARE(spy->count(), 3); + QCOMPARE(spy->size(), 3); // Count notifications triggered; should only happen on actual change. int updateCount = 0; @@ -177,7 +177,7 @@ void testReadWritePropertyBasics( QPROPERTY_TEST_COMPARISON_HELPER(propObserverLambda.value(), changed, comparator, represent); QCOMPARE(updateCount, 1); if (spy) - QCOMPARE(spy->count(), 4); + QCOMPARE(spy->size(), 4); // Test that manually setting the value (even the same one) breaks the // binding. @@ -188,7 +188,7 @@ void testReadWritePropertyBasics( // value didn't change -> the signal should not be emitted if (spy) - QCOMPARE(spy->count(), 4); + QCOMPARE(spy->size(), 4); } /*! @@ -287,7 +287,7 @@ void testWriteOncePropertyBasics( represent); QPROPERTY_TEST_COMPARISON_HELPER(propObserver.value(), changed, comparator, represent); if (spy) - QCOMPARE(spy->count(), 1); + QCOMPARE(spy->size(), 1); // Attempt to set back the 'prior' value and verify that it has no effect testedObj.setProperty(propertyName, QVariant::fromValue(prior)); @@ -296,7 +296,7 @@ void testWriteOncePropertyBasics( represent); QPROPERTY_TEST_COMPARISON_HELPER(propObserver.value(), changed, comparator, represent); if (spy) - QCOMPARE(spy->count(), 1); + QCOMPARE(spy->size(), 1); if (bindingPreservedOnWrite) QVERIFY(bindable.hasBinding()); else @@ -386,7 +386,7 @@ void testReadOnlyPropertyBasics( testedObj.property(propertyName).template value<PropertyType>(), initial, comparator, represent); if (spy) - QCOMPARE(spy->count(), 0); + QCOMPARE(spy->size(), 0); QProperty<PropertyType> propObserver; propObserver.setBinding(bindable.makeBinding()); @@ -402,7 +402,7 @@ void testReadOnlyPropertyBasics( QPROPERTY_TEST_COMPARISON_HELPER(propObserver.value(), changed, comparator, represent); if (spy) - QCOMPARE(spy->count(), 1); + QCOMPARE(spy->size(), 1); } } // namespace QTestPrivate diff --git a/src/testlib/qsignaldumper.cpp b/src/testlib/qsignaldumper.cpp index 7bef9a8f11..86c6c521ff 100644 --- a/src/testlib/qsignaldumper.cpp +++ b/src/testlib/qsignaldumper.cpp @@ -60,7 +60,7 @@ static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv str += " ("; QList<QByteArray> args = member.parameterTypes(); - for (int i = 0; i < args.count(); ++i) { + for (int i = 0; i < args.size(); ++i) { const QByteArray &arg = args.at(i); int typeId = QMetaType::fromName(args.at(i).constData()).id(); if (arg.endsWith('*') || arg.endsWith('&')) { diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index efe07f0360..e93e6d3fc8 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -97,11 +97,11 @@ public: bool wait(int timeout = 5000) { Q_ASSERT(!m_waiting); - const int origCount = count(); + const int origCount = size(); m_waiting = true; m_loop.enterLoopMSecs(timeout); m_waiting = false; - return count() > origCount; + return size() > origCount; } int qt_metacall(QMetaObject::Call call, int methodId, void **a) override @@ -177,8 +177,8 @@ private: void appendArgs(void **a) { QList<QVariant> list; - list.reserve(args.count()); - for (int i = 0; i < args.count(); ++i) { + list.reserve(args.size()); + for (int i = 0; i < args.size(); ++i) { const QMetaType::Type type = static_cast<QMetaType::Type>(args.at(i)); if (type == QMetaType::QVariant) list << *reinterpret_cast<QVariant *>(a[i + 1]); diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index e185e81eb8..8e1a048afc 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -61,7 +61,7 @@ template<> inline char *toString(const QLatin1StringView &str) template<> inline char *toString(const QByteArray &ba) { - return QTest::toPrettyCString(ba.constData(), ba.length()); + return QTest::toPrettyCString(ba.constData(), ba.size()); } template<> inline char *toString(const QBitArray &ba) diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp index 7b64942e7b..d5d5c5c1f2 100644 --- a/src/testlib/qtestblacklist.cpp +++ b/src/testlib/qtestblacklist.cpp @@ -257,7 +257,7 @@ void parseBlackList() if (line.isEmpty()) continue; if (line.startsWith('[')) { - function = line.mid(1, line.length() - 2); + function = line.mid(1, line.size() - 2); continue; } bool condition = checkCondition(line); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d9c7dffdc7..b5ec075215 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -642,7 +642,7 @@ static void qPrintDataTags(FILE *stream) // Print all tag combinations: if (gTable->dataCount() == 0) { - if (localTags.count() == 0) { + if (localTags.size() == 0) { // No tags at all, so just print the test function: fprintf(stream, "%s %s\n", currTestMetaObj->className(), slot); } else { @@ -654,7 +654,7 @@ static void qPrintDataTags(FILE *stream) } } else { for (int j = 0; j < gTable->dataCount(); ++j) { - if (localTags.count() == 0) { + if (localTags.size() == 0) { // Only global tags, so print the current one: fprintf( stream, "%s %s __global__ %s\n", @@ -1056,7 +1056,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) { QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container) { - const int count = container.count(); + const int count = container.size(); if (count == 0) return QBenchmarkResult(); @@ -2392,7 +2392,7 @@ void QTest::qCleanup() */ int QTest::qExec(QObject *testObject, const QStringList &arguments) { - const int argc = arguments.count(); + const int argc = arguments.size(); QVarLengthArray<char *> argv(argc); QList<QByteArray> args; @@ -2642,7 +2642,7 @@ QSharedPointer<QTemporaryDir> QTest::qExtractTestData(const QString &dirName) QFileInfo fileInfo = it.nextFileInfo(); if (!fileInfo.isDir()) { - const QString destination = dataPath + u'/' + QStringView{fileInfo.filePath()}.mid(resourcePath.length()); + const QString destination = dataPath + u'/' + QStringView{fileInfo.filePath()}.mid(resourcePath.size()); QFileInfo destinationFileInfo(destination); QDir().mkpath(destinationFileInfo.path()); if (!QFile::copy(fileInfo.filePath(), destination)) { diff --git a/src/testlib/qtestevent.h b/src/testlib/qtestevent.h index 80745ed9bf..8f092cf8c9 100644 --- a/src/testlib/qtestevent.h +++ b/src/testlib/qtestevent.h @@ -132,7 +132,7 @@ class QTestEventList: public QList<QTestEvent *> public: inline QTestEventList() {} inline QTestEventList(const QTestEventList &other): QList<QTestEvent *>() - { for (int i = 0; i < other.count(); ++i) append(other.at(i)->clone()); } + { for (int i = 0; i < other.size(); ++i) append(other.at(i)->clone()); } inline ~QTestEventList() { clear(); } inline void clear() @@ -182,7 +182,7 @@ public: #ifdef QT_WIDGETS_LIB inline void simulate(QWidget *w) { - for (int i = 0; i < count(); ++i) + for (int i = 0; i < size(); ++i) at(i)->simulate(w); } #endif diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index efa11afbde..b051bd9124 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -259,7 +259,7 @@ namespace QTest inline static void keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { - for (int i=0; i < sequence.length(); i++) + for (int i=0; i < sequence.size(); i++) keyEvent(Click, widget, sequence.at(i).toLatin1(), modifier, delay); } diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index f7b75d5502..e411bb61e6 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -116,7 +116,7 @@ namespace QTest { // (the space was added automatically by ~QDebug() until Qt 5.3, // so autotests still might expect it) if (expected.endsWith(u' ')) - return actual == QStringView{expected}.left(expected.length() - 1); + return actual == QStringView{expected}.left(expected.size() - 1); return false; } diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 97338d3e6b..9c84834f71 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -646,10 +646,10 @@ bool quasiLexicographicalReverseLessThan(const QFileInfo &fi1, const QFileInfo & QString s1 = fi1.baseName(); QString s2 = fi2.baseName(); - if (s1.length() == s2.length()) + if (s1.size() == s2.size()) return s1 > s2; else - return s1.length() > s2.length(); + return s1.size() > s2.size(); } // Files which contain templates that need to be overwritten by build data should be overwritten every @@ -739,10 +739,10 @@ QString cleanPackageName(QString packageName) // No keywords qsizetype index = -1; - while (index < packageName.length()) { + while (index < packageName.size()) { qsizetype next = packageName.indexOf(u'.', index + 1); if (next == -1) - next = packageName.length(); + next = packageName.size(); QString word = packageName.mid(index + 1, next - index - 1); if (!word.isEmpty()) { QChar c = word[0]; @@ -1133,7 +1133,7 @@ bool readInputFile(Options *options) QString subPath = iterator.filePath(); auto arch = fileArchitecture(*options, subPath); if (!arch.isEmpty()) { - options->qtDependencies[arch].append(QtDependency(subPath.mid(options->qtInstallDirectory.length() + 1), + options->qtDependencies[arch].append(QtDependency(subPath.mid(options->qtInstallDirectory.size() + 1), subPath)); } else if (options->verbose) { fprintf(stderr, "Skipping \"%s\", unknown architecture\n", qPrintable(subPath)); @@ -1407,7 +1407,7 @@ bool updateFile(const QString &fileName, const QHash<QString, QString> &replacem forever { int index = contents.indexOf(it.key().toUtf8()); if (index >= 0) { - contents.replace(index, it.key().length(), it.value().toUtf8()); + contents.replace(index, it.key().size(), it.value().toUtf8()); hasReplacements = true; } else { break; @@ -1721,7 +1721,7 @@ QList<QtDependency> findFilesRecursively(const Options &options, const QFileInfo return ret; } else { - return QList<QtDependency>() << QtDependency(info.absoluteFilePath().mid(rootPath.length()), info.absoluteFilePath()); + return QList<QtDependency>() << QtDependency(info.absoluteFilePath().mid(rootPath.size()), info.absoluteFilePath()); } } diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index e6d89d1082..dce092049c 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -72,23 +72,23 @@ QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING) static inline int lengthOfEscapeSequence(const QByteArray &s, int i) { - if (s.at(i) != '\\' || i >= s.length() - 1) + if (s.at(i) != '\\' || i >= s.size() - 1) return 1; const int startPos = i; ++i; char ch = s.at(i); if (ch == 'x') { ++i; - while (i < s.length() && is_hex_char(s.at(i))) + while (i < s.size() && is_hex_char(s.at(i))) ++i; } else if (is_octal_char(ch)) { while (i < startPos + 4 - && i < s.length() + && i < s.size() && is_octal_char(s.at(i))) { ++i; } } else { // single character escape sequence - i = qMin(i + 1, s.length()); + i = qMin(i + 1, s.size()); } return i - startPos; } @@ -96,14 +96,14 @@ static inline int lengthOfEscapeSequence(const QByteArray &s, int i) static inline uint lengthOfEscapedString(const QByteArray &str) { int extra = 0; - for (int j = 0; j < str.length(); ++j) { + for (int j = 0; j < str.size(); ++j) { if (str.at(j) == '\\') { int cnt = lengthOfEscapeSequence(str, j) - 1; extra += cnt; j += cnt; } } - return str.length() - extra; + return str.size() - extra; } // Prints \a s to \a out, breaking it into lines of at most ColumnWidth. The @@ -111,7 +111,7 @@ static inline uint lengthOfEscapedString(const QByteArray &str) static void printStringWithIndentation(FILE *out, const QByteArray &s) { static constexpr int ColumnWidth = 72; - int len = s.length(); + int len = s.size(); int idx = 0; do { @@ -146,8 +146,8 @@ int Generator::stridx(const QByteArray &s) static int aggregateParameterCount(const QList<FunctionDef> &list) { int sum = 0; - for (int i = 0; i < list.count(); ++i) - sum += list.at(i).arguments.count() + 1; // +1 for return type + for (int i = 0; i < list.size(); ++i) + sum += list.at(i).arguments.size() + 1; // +1 for return type return sum; } @@ -218,7 +218,7 @@ void Generator::generateCode() // filter out undeclared enumerators and sets { QList<EnumDef> enumList; - for (int i = 0; i < cdef->enumList.count(); ++i) { + for (int i = 0; i < cdef->enumList.size(); ++i) { EnumDef def = cdef->enumList.at(i); if (cdef->enumDeclarations.contains(def.name)) { enumList += def; @@ -280,7 +280,7 @@ void Generator::generateCode() int idx = 0; for (int i = 0; i < strings.size(); ++i) { const QByteArray &str = strings.at(i); - const QByteArray comment = str.length() > 32 ? str.left(29) + "..." : str; + const QByteArray comment = str.size() > 32 ? str.left(29) + "..." : str; const char *comma = (i != strings.size() - 1 ? "," : " "); int len = lengthOfEscapedString(str); fprintf(out, "\n QT_MOC_LITERAL(%d, %d)%s // \"%s\"", idx, len, comma, @@ -314,10 +314,10 @@ void Generator::generateCode() fprintf(out, "\n // content:\n"); fprintf(out, " %4d, // revision\n", int(QMetaObjectPrivate::OutputRevision)); fprintf(out, " %4d, // classname\n", stridx(cdef->qualified)); - fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.count()), int(cdef->classInfoList.count() ? index : 0)); - index += cdef->classInfoList.count() * 2; + fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.size()), int(cdef->classInfoList.size() ? index : 0)); + index += cdef->classInfoList.size() * 2; - int methodCount = cdef->signalList.count() + cdef->slotList.count() + cdef->methodList.count(); + int methodCount = cdef->signalList.size() + cdef->slotList.size() + cdef->methodList.size(); fprintf(out, " %4d, %4d, // methods\n", methodCount, methodCount ? index : 0); index += methodCount * QMetaObjectPrivate::IntsPerMethod; if (cdef->revisionedMethods) @@ -329,16 +329,16 @@ void Generator::generateCode() + aggregateParameterCount(cdef->constructorList); index += totalParameterCount * 2 // types and parameter names - methodCount // return "parameters" don't have names - - cdef->constructorList.count(); // "this" parameters don't have names + - cdef->constructorList.size(); // "this" parameters don't have names - fprintf(out, " %4d, %4d, // properties\n", int(cdef->propertyList.count()), int(cdef->propertyList.count() ? index : 0)); - index += cdef->propertyList.count() * QMetaObjectPrivate::IntsPerProperty; - fprintf(out, " %4d, %4d, // enums/sets\n", int(cdef->enumList.count()), cdef->enumList.count() ? index : 0); + fprintf(out, " %4d, %4d, // properties\n", int(cdef->propertyList.size()), int(cdef->propertyList.size() ? index : 0)); + index += cdef->propertyList.size() * QMetaObjectPrivate::IntsPerProperty; + fprintf(out, " %4d, %4d, // enums/sets\n", int(cdef->enumList.size()), cdef->enumList.size() ? index : 0); int enumsIndex = index; - for (int i = 0; i < cdef->enumList.count(); ++i) - index += 5 + (cdef->enumList.at(i).values.count() * 2); - fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? int(cdef->constructorList.count()) : 0, + for (int i = 0; i < cdef->enumList.size(); ++i) + index += 5 + (cdef->enumList.at(i).values.size() * 2); + fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? int(cdef->constructorList.size()) : 0, isConstructible ? index : 0); int flags = 0; @@ -348,7 +348,7 @@ void Generator::generateCode() flags |= PropertyAccessInStaticMetaCall; } fprintf(out, " %4d, // flags\n", flags); - fprintf(out, " %4d, // signalCount\n", int(cdef->signalList.count())); + fprintf(out, " %4d, // signalCount\n", int(cdef->signalList.size())); // @@ -357,7 +357,7 @@ void Generator::generateCode() generateClassInfos(); // all property metatypes, + 1 for the type of the current class itself - int initialMetaTypeOffset = cdef->propertyList.count() + 1; + int initialMetaTypeOffset = cdef->propertyList.size() + 1; // // Build signals array first, otherwise the signal indices would be wrong @@ -420,7 +420,7 @@ void Generator::generateCode() QMultiHash<QByteArray, QByteArray> knownExtraMetaObject(knownGadgets); knownExtraMetaObject.unite(knownQObjectClasses); - for (int i = 0; i < cdef->propertyList.count(); ++i) { + for (int i = 0; i < cdef->propertyList.size(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); if (isBuiltinType(p.type)) continue; @@ -480,7 +480,7 @@ void Generator::generateCode() if (!extraList.isEmpty()) { fprintf(out, "Q_CONSTINIT static const QMetaObject::SuperData qt_meta_extradata_%s[] = {\n", qualifiedClassNameIdentifier.constData()); - for (int i = 0; i < extraList.count(); ++i) { + for (int i = 0; i < extraList.size(); ++i) { fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", extraList.at(i).constData()); } fprintf(out, " nullptr\n};\n\n"); @@ -528,7 +528,7 @@ void Generator::generateCode() fprintf(out, " qt_metaTypeArray<"); } // metatypes for properties - for (int i = 0; i < cdef->propertyList.count(); ++i) { + for (int i = 0; i < cdef->propertyList.size(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); fprintf(out, "%s\n // property '%s'\n %s", comma, p.name.constData(), stringForType(p.type, true).constData()); @@ -545,7 +545,7 @@ void Generator::generateCode() // because we definitely printed something above, this section doesn't need comma control for (const QList<FunctionDef> &methodContainer : { cdef->signalList, cdef->slotList, cdef->methodList }) { - for (int i = 0; i< methodContainer.count(); ++i) { + for (int i = 0; i< methodContainer.size(); ++i) { const FunctionDef& fdef = methodContainer.at(i); fprintf(out, ",\n // method '%s'\n %s", fdef.name.constData(), stringForType(fdef.type.name, false).constData()); @@ -555,7 +555,7 @@ void Generator::generateCode() } // but constructors have no return types, so this needs comma control again - for (int i = 0; i< cdef->constructorList.count(); ++i) { + for (int i = 0; i< cdef->constructorList.size(); ++i) { const FunctionDef& fdef = cdef->constructorList.at(i); if (fdef.arguments.isEmpty()) continue; @@ -672,7 +672,7 @@ void Generator::generateClassInfos() void Generator::registerFunctionStrings(const QList<FunctionDef> &list) { - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { const FunctionDef &f = list.at(i); strreg(f.name); @@ -680,7 +680,7 @@ void Generator::registerFunctionStrings(const QList<FunctionDef> &list) strreg(f.normalizedType); strreg(f.tag); - int argsCount = f.arguments.count(); + int argsCount = f.arguments.size(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (!isBuiltinType(a.normalizedType)) @@ -703,7 +703,7 @@ void Generator::generateFunctions(const QList<FunctionDef> &list, const char *fu return; fprintf(out, "\n // %ss: name, argc, parameters, tag, flags, initial metatype offsets\n", functype); - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { const FunctionDef &f = list.at(i); QByteArray comment; @@ -740,7 +740,7 @@ void Generator::generateFunctions(const QList<FunctionDef> &list, const char *fu comment.append(" | MethodIsConst "); } - int argc = f.arguments.count(); + int argc = f.arguments.size(); fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x, %4d /* %s */,\n", stridx(f.name), argc, paramsIndex, stridx(f.tag), flags, initialMetatypeOffset, comment.constData()); @@ -752,9 +752,9 @@ void Generator::generateFunctions(const QList<FunctionDef> &list, const char *fu void Generator::generateFunctionRevisions(const QList<FunctionDef> &list, const char *functype) { - if (list.count()) + if (list.size()) fprintf(out, "\n // %ss: revision\n", functype); - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { const FunctionDef &f = list.at(i); fprintf(out, " %4d,\n", f.revision); } @@ -765,12 +765,12 @@ void Generator::generateFunctionParameters(const QList<FunctionDef> &list, const if (list.isEmpty()) return; fprintf(out, "\n // %ss: parameters\n", functype); - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { const FunctionDef &f = list.at(i); fprintf(out, " "); // Types - int argsCount = f.arguments.count(); + int argsCount = f.arguments.size(); for (int j = -1; j < argsCount; ++j) { if (j > -1) fputc(' ', out); @@ -816,7 +816,7 @@ void Generator::generateTypeInfo(const QByteArray &typeName, bool allowEmptyName void Generator::registerPropertyStrings() { - for (int i = 0; i < cdef->propertyList.count(); ++i) { + for (int i = 0; i < cdef->propertyList.size(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); strreg(p.name); if (!isBuiltinType(p.type)) @@ -830,9 +830,9 @@ void Generator::generateProperties() // Create meta data // - if (cdef->propertyList.count()) + if (cdef->propertyList.size()) fprintf(out, "\n // properties: name, type, flags\n"); - for (int i = 0; i < cdef->propertyList.count(); ++i) { + for (int i = 0; i < cdef->propertyList.size(); ++i) { const PropertyDef &p = cdef->propertyList.at(i); uint flags = Invalid; if (!isBuiltinType(p.type)) @@ -886,12 +886,12 @@ void Generator::generateProperties() void Generator::registerEnumStrings() { - for (int i = 0; i < cdef->enumList.count(); ++i) { + for (int i = 0; i < cdef->enumList.size(); ++i) { const EnumDef &e = cdef->enumList.at(i); strreg(e.name); if (!e.enumName.isNull()) strreg(e.enumName); - for (int j = 0; j < e.values.count(); ++j) + for (int j = 0; j < e.values.size(); ++j) strreg(e.values.at(j)); } } @@ -902,9 +902,9 @@ void Generator::generateEnums(int index) return; fprintf(out, "\n // enums: name, alias, flags, count, data\n"); - index += 5 * cdef->enumList.count(); + index += 5 * cdef->enumList.size(); int i; - for (i = 0; i < cdef->enumList.count(); ++i) { + for (i = 0; i < cdef->enumList.size(); ++i) { const EnumDef &e = cdef->enumList.at(i); int flags = 0; if (cdef->enumDeclarations.value(e.name)) @@ -915,15 +915,15 @@ void Generator::generateEnums(int index) stridx(e.name), e.enumName.isNull() ? stridx(e.name) : stridx(e.enumName), flags, - int(e.values.count()), + int(e.values.size()), index); - index += e.values.count() * 2; + index += e.values.size() * 2; } fprintf(out, "\n // enum data: key, value\n"); - for (i = 0; i < cdef->enumList.count(); ++i) { + for (i = 0; i < cdef->enumList.size(); ++i) { const EnumDef &e = cdef->enumList.at(i); - for (int j = 0; j < e.values.count(); ++j) { + for (int j = 0; j < e.values.size(); ++j) { const QByteArray &val = e.values.at(j); QByteArray code = cdef->qualified.constData(); if (e.isEnumClass) @@ -989,7 +989,7 @@ void Generator::generateMetacall() " || _c == QMetaObject::ResetProperty || _c == QMetaObject::BindableProperty\n" " || _c == QMetaObject::RegisterPropertyMetaType) {\n" " qt_static_metacall(this, _c, _id, _a);\n" - " _id -= %d;\n }", int(cdef->propertyList.count())); + " _id -= %d;\n }", int(cdef->propertyList.size())); } if (methodList.size() || cdef->propertyList.size()) fprintf(out, "\n "); @@ -1015,7 +1015,7 @@ Generator::methodsWithAutomaticTypesHelper(const QList<FunctionDef> &methodList) QMap<int, QMultiMap<QByteArray, int> > methodsWithAutomaticTypes; for (int i = 0; i < methodList.size(); ++i) { const FunctionDef &f = methodList.at(i); - for (int j = 0; j < f.arguments.count(); ++j) { + for (int j = 0; j < f.arguments.size(); ++j) { const QByteArray argType = f.arguments.at(j).normalizedType; if (registerableMetaType(argType) && !isBuiltinType(argType)) methodsWithAutomaticTypes[i].insert(argType, j); @@ -1035,13 +1035,13 @@ void Generator::generateStaticMetacall() if (!cdef->constructorList.isEmpty()) { fprintf(out, " if (_c == QMetaObject::CreateInstance) {\n"); fprintf(out, " switch (_id) {\n"); - for (int ctorindex = 0; ctorindex < cdef->constructorList.count(); ++ctorindex) { + for (int ctorindex = 0; ctorindex < cdef->constructorList.size(); ++ctorindex) { fprintf(out, " case %d: { %s *_r = new %s(", ctorindex, cdef->classname.constData(), cdef->classname.constData()); const FunctionDef &f = cdef->constructorList.at(ctorindex); int offset = 1; - int argsCount = f.arguments.count(); + int argsCount = f.arguments.size(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1100,7 +1100,7 @@ void Generator::generateStaticMetacall() if (f.isRawSlot) { fprintf(out, "QMethodRawArguments{ _a }"); } else { - int argsCount = f.arguments.count(); + int argsCount = f.arguments.size(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1170,7 +1170,7 @@ void Generator::generateStaticMetacall() fprintf(out, " {\n"); fprintf(out, " using _t = %s (%s::*)(",f.type.rawName.constData() , cdef->classname.constData()); - int argsCount = f.arguments.count(); + int argsCount = f.arguments.size(); for (int j = 0; j < argsCount; ++j) { const ArgumentDef &a = f.arguments.at(j); if (j) @@ -1427,7 +1427,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } int offset = 1; - for (int j = 0; j < def->arguments.count(); ++j) { + for (int j = 0; j < def->arguments.size(); ++j) { const ArgumentDef &a = def->arguments.at(j); if (j) fputs(", ", out); @@ -1460,7 +1460,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } int i; for (i = 1; i < offset; ++i) - if (i <= def->arguments.count() && def->arguments.at(i - 1).type.isVolatile) + if (i <= def->arguments.size() && def->arguments.at(i - 1).type.isVolatile) fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t%d)))", i); else fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t%d)))", i); diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 71b9757ebc..eb359f4dbb 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -330,7 +330,7 @@ int runMoc(int argc, char **argv) if (parser.isSet(collectOption)) return collectJson(files, output, hasOptionFiles); - if (files.count() > 1) { + if (files.size() > 1) { error(qPrintable("Too many input files specified: '"_L1 + files.join("' '"_L1) + u'\'')); parser.showHelp(1); } else if (!files.isEmpty()) { diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 461382092e..381d262b68 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -368,7 +368,7 @@ QTypeRevision Moc::parseRevision() revisionString.remove(0, 1); revisionString.chop(1); const QList<QByteArray> majorMinor = revisionString.split(','); - switch (majorMinor.length()) { + switch (majorMinor.size()) { case 1: { bool ok = false; const int revision = revisionString.toInt(&ok); @@ -1066,7 +1066,7 @@ static QByteArrayList requiredQtContainers(const QList<ClassDef> &classes) void Moc::generate(FILE *out, FILE *jsonOutput) { QByteArray fn = filename; - int i = filename.length()-1; + int i = filename.size()-1; while (i > 0 && filename.at(i - 1) != '/' && filename.at(i - 1) != '\\') --i; // skip path if (i >= 0) @@ -1315,7 +1315,7 @@ void Moc::parsePropertyAttributes(PropertyDef &propDef) QByteArray v, v2; if (test(LPAREN)) { v = lexemUntil(RPAREN); - v = v.mid(1, v.length() - 2); // removes the '(' and ')' + v = v.mid(1, v.size() - 2); // removes the '(' and ')' } else if (test(INTEGER_LITERAL)) { v = lexem(); if (l != "REVISION") @@ -1596,7 +1596,7 @@ void Moc::parseInterfaces(ClassDef *def) } } // resolve from classnames to interface ids - for (int i = 0; i < iface.count(); ++i) { + for (int i = 0; i < iface.size(); ++i) { const QByteArray iid = interface2IdMap.value(iface.at(i).className); if (iid.isEmpty()) error("Undefined interface"); @@ -1792,7 +1792,7 @@ void Moc::checkSuperClasses(ClassDef *def) #endif return; } - for (int i = 1; i < def->superclassList.count(); ++i) { + for (int i = 1; i < def->superclassList.size(); ++i) { const QByteArray superClass = def->superclassList.at(i).first; if (knownQObjectClasses.contains(superClass)) { const QByteArray msg @@ -1808,7 +1808,7 @@ void Moc::checkSuperClasses(ClassDef *def) if (interface2IdMap.contains(superClass)) { bool registeredInterface = false; - for (int i = 0; i < def->interfaceList.count(); ++i) + for (int i = 0; i < def->interfaceList.size(); ++i) if (def->interfaceList.at(i).constFirst().className == superClass) { registeredInterface = true; break; @@ -1835,8 +1835,8 @@ void Moc::checkProperties(ClassDef *cdef) // specify get function, for compatibility we accept functions // returning pointers, or const char * for QByteArray. // - QDuplicateTracker<QByteArray> definedProperties(cdef->propertyList.count()); - for (int i = 0; i < cdef->propertyList.count(); ++i) { + QDuplicateTracker<QByteArray> definedProperties(cdef->propertyList.size()); + for (int i = 0; i < cdef->propertyList.size(); ++i) { PropertyDef &p = cdef->propertyList[i]; if (definedProperties.hasSeen(p.name)) { QByteArray msg = "The property '" + p.name + "' is defined multiple times in class " + cdef->classname + "."; @@ -1858,7 +1858,7 @@ void Moc::checkProperties(ClassDef *cdef) continue; } - for (int j = 0; j < cdef->publicList.count(); ++j) { + for (int j = 0; j < cdef->publicList.size(); ++j) { const FunctionDef &f = cdef->publicList.at(j); if (f.name != p.read) continue; @@ -1885,7 +1885,7 @@ void Moc::checkProperties(ClassDef *cdef) } if (!p.notify.isEmpty()) { int notifyId = -1; - for (int j = 0; j < cdef->signalList.count(); ++j) { + for (int j = 0; j < cdef->signalList.size(); ++j) { const FunctionDef &f = cdef->signalList.at(j); if (f.name != p.notify) { continue; @@ -1899,7 +1899,7 @@ void Moc::checkProperties(ClassDef *cdef) int index = cdef->nonClassSignalList.indexOf(p.notify); if (index == -1) { cdef->nonClassSignalList << p.notify; - p.notifyId = -1 - cdef->nonClassSignalList.count(); + p.notifyId = -1 - cdef->nonClassSignalList.size(); } else { p.notifyId = -2 - index; } diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index c27b2c633f..843a684bda 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -276,8 +276,8 @@ inline QByteArray noRef(const QByteArray &type) { if (type.endsWith('&')) { if (type.endsWith("&&")) - return type.left(type.length()-2); - return type.left(type.length()-1); + return type.left(type.size()-2); + return type.left(type.size()-1); } return type; } diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index a0c0b7ffaa..0958e26be3 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -980,7 +980,7 @@ static void mergeStringLiterals(Symbols *_symbols) for (Symbols::iterator j = mergeSymbol + 1; j != i; ++j) mergeSymbolLexem.append(j->lex.constData() + j->from + 1, j->len - 2); // append j->unquotedLexem() mergeSymbolLexem.append('"'); - mergeSymbol->len = mergeSymbol->lex.length(); + mergeSymbol->len = mergeSymbol->lex.size(); mergeSymbol->from = 0; i = symbols.erase(mergeSymbol + 1, i); } @@ -1284,7 +1284,7 @@ void Preprocessor::parseDefineArguments(Macro *m) if (!test(PP_RPAREN)) error("missing ')' in macro argument list"); break; - } else if (!is_identifier(l.constData(), l.length())) { + } else if (!is_identifier(l.constData(), l.size())) { error("Unexpected character in macro argument list."); } } diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 90fa13503d..928b82e7da 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -110,13 +110,13 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { qWarning() << qPrintable(errorMsg); return QString(); // invalid form } - if (isSignal && inputCount + 1 != types.count()) + if (isSignal && inputCount + 1 != types.size()) return QString(); // signal with output arguments? if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message()) return QString(); // signal with QDBusMessage argument? bool isScriptable = mm.isScriptable; - for (int j = 1; j < types.count(); ++j) { + for (int j = 1; j < types.size(); ++j) { // input parameter for a slot or output for a signal if (types.at(j) == QDBusMetaTypeId::message()) { isScriptable = true; @@ -253,7 +253,7 @@ QString qDBusInterfaceFromClassDef(const ClassDef *mo) if (interface.startsWith("QDBus"_L1)) { interface.prepend("org.qtproject.QtDBus."_L1); } else if (interface.startsWith(u'Q') && - interface.length() >= 2 && interface.at(1).isUpper()) { + interface.size() >= 2 && interface.at(1).isUpper()) { // assume it's Qt interface.prepend("local.org.qtproject.Qt."_L1); } else { @@ -333,7 +333,7 @@ static std::deque<CustomType> s_customTypes; static void parseCmdLine(QStringList &arguments) { flags = 0; - for (int i = 0; i < arguments.count(); ++i) { + for (int i = 0; i < arguments.size(); ++i) { const QString arg = arguments.at(i); if (arg == "--help"_L1) @@ -373,7 +373,7 @@ static void parseCmdLine(QStringList &arguments) break; case 't': - if (arguments.count() < i + 2) { + if (arguments.size() < i + 2) { printf("-t expects a type=dbustype argument\n"); exit(1); } else { @@ -394,7 +394,7 @@ static void parseCmdLine(QStringList &arguments) break; case 'o': - if (arguments.count() < i + 2 || arguments.at(i + 1).startsWith(u'-')) { + if (arguments.size() < i + 2 || arguments.at(i + 1).startsWith(u'-')) { printf("-o expects a filename\n"); exit(1); } @@ -431,7 +431,7 @@ int main(int argc, char **argv) QList<ClassDef> classes; - for (int i = 0; i < args.count(); ++i) { + for (int i = 0; i < args.size(); ++i) { const QString arg = args.at(i); if (arg.startsWith(u'-')) diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index e3acefcdbe..4f695d0505 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -121,7 +121,7 @@ static QString moc(const QString &name) if (retval.isEmpty()) return retval; - retval.truncate(retval.length() - 1); // drop the h in .h + retval.truncate(retval.size() - 1); // drop the h in .h retval += "moc"_L1; return retval; } @@ -247,8 +247,8 @@ static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs, QDBusIntrospection::Arguments()) { QStringList retval; - const int numInputArgs = inputArgs.count(); - const int numOutputArgs = outputArgs.count(); + const int numInputArgs = inputArgs.size(); + const int numOutputArgs = outputArgs.size(); retval.reserve(numInputArgs + numOutputArgs); for (int i = 0; i < numInputArgs; ++i) { const QDBusIntrospection::Argument &arg = inputArgs.at(i); @@ -283,7 +283,7 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames, // input args: bool first = true; int argPos = 0; - for (int i = 0; i < inputArgs.count(); ++i) { + for (int i = 0; i < inputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = inputArgs.at(i); QString type = constRefArg(qtTypeName(arg.name, arg.type, annotations, i, "In")); @@ -297,7 +297,7 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames, // output args // yes, starting from 1 - for (int i = 1; i < outputArgs.count(); ++i) { + for (int i = 1; i < outputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = outputArgs.at(i); if (!first) @@ -314,7 +314,7 @@ static void writeSignalArgList(QTextStream &ts, const QStringList &argNames, { bool first = true; int argPos = 0; - for (int i = 0; i < outputArgs.count(); ++i) { + for (int i = 0; i < outputArgs.size(); ++i) { const QDBusIntrospection::Argument &arg = outputArgs.at(i); QString type = constRefArg( qtTypeName(arg.name, arg.type, annotations, i, "Out", true /* isSignal */)); @@ -379,14 +379,14 @@ static QString stringify(const QString &data) { QString retval; int i; - for (i = 0; i < data.length(); ++i) { + for (i = 0; i < data.size(); ++i) { retval += u'\"'; - for ( ; i < data.length() && data[i] != u'\n' && data[i] != u'\r'; ++i) + for ( ; i < data.size() && data[i] != u'\n' && data[i] != u'\r'; ++i) if (data[i] == u'\"') retval += "\\\""_L1; else retval += data[i]; - if (i+1 < data.length() && data[i] == u'\r' && data[i+1] == u'\n') + if (i+1 < data.size() && data[i] == u'\r' && data[i+1] == u'\n') i++; retval += "\\n\"\n"_L1; } @@ -562,7 +562,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf hs << "Q_NOREPLY void "; } else { hs << "QDBusPendingReply<"; - for (int i = 0; i < method.outputArgs.count(); ++i) + for (int i = 0; i < method.outputArgs.size(); ++i) hs << (i > 0 ? ", " : "") << templateArg(qtTypeName(method.outputArgs.at(i).name, method.outputArgs.at(i).type, method.annotations, i, "Out")); @@ -580,7 +580,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (!method.inputArgs.isEmpty()) { hs << " argumentList"; - for (int argPos = 0; argPos < method.inputArgs.count(); ++argPos) + for (int argPos = 0; argPos < method.inputArgs.size(); ++argPos) hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << Qt::endl; } @@ -595,7 +595,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf // close the function: hs << " }" << Qt::endl; - if (method.outputArgs.count() > 1) { + if (method.outputArgs.size() > 1) { // generate the old-form QDBusReply methods with multiple incoming parameters hs << " inline " << (isDeprecated ? "Q_DECL_DEPRECATED " : "") << "QDBusReply<" << templateArg(qtTypeName(method.outputArgs.first().name, method.outputArgs.first().type, @@ -613,7 +613,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf int argPos = 0; if (!method.inputArgs.isEmpty()) { hs << " argumentList"; - for (argPos = 0; argPos < method.inputArgs.count(); ++argPos) + for (argPos = 0; argPos < method.inputArgs.size(); ++argPos) hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << Qt::endl; } @@ -623,10 +623,10 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf argPos++; hs << " if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == " - << method.outputArgs.count() << ") {" << Qt::endl; + << method.outputArgs.size() << ") {" << Qt::endl; // yes, starting from 1 - for (int i = 1; i < method.outputArgs.count(); ++i) + for (int i = 1; i < method.outputArgs.size(); ++i) hs << " " << argNames.at(argPos++) << " = qdbus_cast<" << templateArg(qtTypeName(method.outputArgs.at(i).name, method.outputArgs.at(i).type, method.annotations, i, "Out")) @@ -671,21 +671,21 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf } int i = 0; - while (i < current.count() && i < last.count() && current.at(i) == last.at(i)) + while (i < current.size() && i < last.size() && current.at(i) == last.at(i)) ++i; // i parts matched // close last.arguments().count() - i namespaces: - for (int j = i; j < last.count(); ++j) - hs << QString((last.count() - j - 1 + i) * 2, u' ') << "}" << Qt::endl; + for (int j = i; j < last.size(); ++j) + hs << QString((last.size() - j - 1 + i) * 2, u' ') << "}" << Qt::endl; // open current.arguments().count() - i namespaces - for (int j = i; j < current.count(); ++j) + for (int j = i; j < current.size(); ++j) hs << QString(j * 2, u' ') << "namespace " << current.at(j) << " {" << Qt::endl; // add this class: if (!name.isEmpty()) { - hs << QString(current.count() * 2, u' ') + hs << QString(current.size() * 2, u' ') << "using " << name << " = ::" << classNameForInterface(it->constData()->name, Proxy) << ";" << Qt::endl; } @@ -920,14 +920,14 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte // make the call bool usingInvokeMethod = false; - if (parentClassName.isEmpty() && method.inputArgs.count() <= 10 - && method.outputArgs.count() <= 1) + if (parentClassName.isEmpty() && method.inputArgs.size() <= 10 + && method.outputArgs.size() <= 1) usingInvokeMethod = true; if (usingInvokeMethod) { // we are using QMetaObject::invokeMethod if (!returnType.isEmpty()) - cs << " " << returnType << " " << argNames.at(method.inputArgs.count()) + cs << " " << returnType << " " << argNames.at(method.inputArgs.size()) << ";" << Qt::endl; static const char invoke[] = " QMetaObject::invokeMethod(parent(), \""; @@ -937,9 +937,9 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte cs << ", Q_RETURN_ARG(" << qtTypeName(method.outputArgs.at(0).name, method.outputArgs.at(0).type, method.annotations, 0, "Out") - << ", " << argNames.at(method.inputArgs.count()) << ")"; + << ", " << argNames.at(method.inputArgs.size()) << ")"; - for (int i = 0; i < method.inputArgs.count(); ++i) + for (int i = 0; i < method.inputArgs.size(); ++i) cs << ", Q_ARG(" << qtTypeName(method.inputArgs.at(i).name, method.inputArgs.at(i).type, method.annotations, i, "In") @@ -948,7 +948,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte cs << ");" << Qt::endl; if (!returnType.isEmpty()) - cs << " return " << argNames.at(method.inputArgs.count()) << ";" << Qt::endl; + cs << " return " << argNames.at(method.inputArgs.size()) << ";" << Qt::endl; } else { if (parentClassName.isEmpty()) cs << " //"; @@ -966,12 +966,12 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte int argPos = 0; bool first = true; - for (int i = 0; i < method.inputArgs.count(); ++i) { + for (int i = 0; i < method.inputArgs.size(); ++i) { cs << (first ? "" : ", ") << argNames.at(argPos++); first = false; } ++argPos; // skip retval, if any - for (int i = 1; i < method.outputArgs.count(); ++i) { + for (int i = 1; i < method.outputArgs.size(); ++i) { cs << (first ? "" : ", ") << argNames.at(argPos++); first = false; } diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index a41aa87835..0a32d9a7f5 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -214,7 +214,7 @@ void CppGenerator::operator () () } auto rule = grammar.rules.begin(); - for (int i = 0; i < used_rules.count (); ++i, ++rule) + for (int i = 0; i < used_rules.size(); ++i, ++rule) { if (! used_rules.testBit (i)) { diff --git a/src/tools/qvkgen/qvkgen.cpp b/src/tools/qvkgen/qvkgen.cpp index 98d87be1b5..84903c2a43 100644 --- a/src/tools/qvkgen/qvkgen.cpp +++ b/src/tools/qvkgen/qvkgen.cpp @@ -606,7 +606,7 @@ int main(int argc, char **argv) QStringLiteral("vkGetInstanceProcAddr"), QStringLiteral("vkEnumerateInstanceVersion") }; - for (int i = 0; i < commands.count(); ++i) { + for (int i = 0; i < commands.size(); ++i) { if (ignoredFuncs.contains(commands[i].cmd.name)) commands.remove(i--); } diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index bb5043e0a2..7241dc516b 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -371,7 +371,7 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) } // write the length - lib.writeNumber2(m_name.length()); + lib.writeNumber2(m_name.size()); if (text || pass1) lib.writeString("\n "); else if (python) @@ -388,14 +388,14 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) // write the m_name const QChar *unicode = m_name.unicode(); - for (int i = 0; i < m_name.length(); ++i) { + for (int i = 0; i < m_name.size(); ++i) { lib.writeNumber2(unicode[i].unicode()); if ((text || pass1) && i % 16 == 0) lib.writeString("\n "); else if (python && i % 16 == 0) lib.writeString("\\\n"); } - offset += m_name.length()*2; + offset += m_name.size()*2; // done if (text || pass1) @@ -506,7 +506,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QString attribute = attributes.value(m_strings.ATTRIBUTE_LANG).toString(); QLocale lang = QLocale(attribute); language = lang.language(); - if (2 == attribute.length()) { + if (2 == attribute.size()) { // Language only territory = QLocale::AnyTerritory; } else { diff --git a/src/tools/shared/shellquote_shared.h b/src/tools/shared/shellquote_shared.h index ea72c89ab3..7a9ab691da 100644 --- a/src/tools/shared/shellquote_shared.h +++ b/src/tools/shared/shellquote_shared.h @@ -11,7 +11,7 @@ // Copy-pasted from qmake/library/ioutil.cpp inline static bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16]) { - for (int x = arg.length() - 1; x >= 0; --x) { + for (int x = arg.size() - 1; x >= 0; --x) { ushort c = arg.unicode()[x].unicode(); if ((c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)))) return true; @@ -27,7 +27,7 @@ static QString shellQuoteUnix(const QString &arg) 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78 }; // 0-32 \'"$`<>|;&(){}*?#!~[] - if (!arg.length()) + if (!arg.size()) return QLatin1String("\"\""); QString ret(arg); @@ -50,7 +50,7 @@ static QString shellQuoteWin(const QString &arg) 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 }; - if (!arg.length()) + if (!arg.size()) return QLatin1String("\"\""); QString ret(arg); @@ -62,7 +62,7 @@ static QString shellQuoteWin(const QString &arg) // The argument must not end with a \ since this would be interpreted // as escaping the quote -- rather put the \ behind the quote: e.g. // rather use "foo"\ than "foo\" - int i = ret.length(); + int i = ret.size(); while (i > 0 && ret.at(i - 1) == QLatin1Char('\\')) --i; ret.insert(i, QLatin1Char('"')); diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp index 2730ef9797..e4ea2fbd40 100644 --- a/src/tools/uic/cpp/cppwritedeclaration.cpp +++ b/src/tools/uic/cpp/cppwritedeclaration.cpp @@ -55,7 +55,7 @@ void WriteDeclaration::acceptUI(DomUI *node) exportMacro.append(u' '); QStringList namespaceList = qualifiedClassName.split("::"_L1); - if (namespaceList.count()) { + if (namespaceList.size()) { className = namespaceList.last(); namespaceList.removeLast(); } @@ -65,7 +65,7 @@ void WriteDeclaration::acceptUI(DomUI *node) // is a User using Qt-in-namespace having his own classes not in a namespace. // In this case the generated Ui helper classes will also end up in // the Qt namespace (which is harmless, but not "pretty") - const bool needsMacro = namespaceList.count() == 0 + const bool needsMacro = namespaceList.size() == 0 || namespaceList[0] == "qdesigner_internal"_L1; if (needsMacro) @@ -73,7 +73,7 @@ void WriteDeclaration::acceptUI(DomUI *node) openNameSpaces(namespaceList, m_output); - if (namespaceList.count()) + if (namespaceList.size()) m_output << "\n"; m_output << "class " << exportMacro << m_option.prefix << className << "\n" @@ -98,7 +98,7 @@ void WriteDeclaration::acceptUI(DomUI *node) closeNameSpaces(namespaceList, m_output); - if (namespaceList.count()) + if (namespaceList.size()) m_output << "\n"; if (m_option.generateNamespace && !m_option.prefix.isEmpty()) { @@ -110,7 +110,7 @@ void WriteDeclaration::acceptUI(DomUI *node) closeNameSpaces(namespaceList, m_output); - if (namespaceList.count()) + if (namespaceList.size()) m_output << "\n"; } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 6a4d039d05..325216c6d0 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -601,7 +601,7 @@ void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWid void WriteInitialization::acceptWidget(DomWidget *node) { - m_layoutMarginType = m_widgetChain.count() == 1 ? TopLevelMargin : ChildMargin; + m_layoutMarginType = m_widgetChain.size() == 1 ? TopLevelMargin : ChildMargin; const QString className = node->attributeClass(); const QString varName = m_driver->findOrInsertWidget(node); @@ -977,7 +977,7 @@ void WriteInitialization::writePropertyList(const QString &varName, if (value.isEmpty()) return; const QStringList list = value.split(u','); - const int count = list.count(); + const int count = list.size(); for (int i = 0; i < count; i++) { if (list.at(i) != defaultValue) { m_output << m_indent << varName << language::derefPointer << setFunction @@ -1180,7 +1180,7 @@ void WriteInitialization::writeProperties(const QString &varName, const DomPropertyList &lst, unsigned flags) { - const bool isTopLevel = m_widgetChain.count() == 1; + const bool isTopLevel = m_widgetChain.size() == 1; if (m_uic->customWidgetsInfo()->extends(className, "QAxWidget")) { DomPropertyMap properties = propertyMap(lst); @@ -2329,7 +2329,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) QString tempName = disableSorting(w, varName); const auto items = initializeTreeWidgetItems(w->elementItem()); - for (int i = 0; i < items.count(); i++) { + for (int i = 0; i < items.size(); i++) { Item *itm = items[i]; itm->writeSetupUi(varName); QString parentPath; diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 87214cc7da..faabe81d5f 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -430,7 +430,7 @@ QAccessibleInterface *QAccessibleAbstractScrollArea::child(int index) const int QAccessibleAbstractScrollArea::childCount() const { - return accessibleChildren().count(); + return accessibleChildren().size(); } int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 64204c2e59..3ac43a4fb3 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -154,21 +154,21 @@ int QAccessibleTable::selectedCellCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedIndexes().count(); + return view()->selectionModel()->selectedIndexes().size(); } int QAccessibleTable::selectedColumnCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedColumns().count(); + return view()->selectionModel()->selectedColumns().size(); } int QAccessibleTable::selectedRowCount() const { if (!view()->selectionModel()) return 0; - return view()->selectionModel()->selectedRows().count(); + return view()->selectionModel()->selectedRows().size(); } QString QAccessibleTable::rowDescription(int row) const @@ -654,7 +654,7 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const return QModelIndex(); const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); - if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.count() <= row)) { + if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.size() <= row)) { qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; return QModelIndex(); } @@ -707,7 +707,7 @@ int QAccessibleTree::childCount() const return 0; int hHeader = horizontalHeader() ? 1 : 0; - return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); + return (treeView->d_func()->viewItems.size() + hHeader)* view()->model()->columnCount(); } QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const @@ -743,7 +743,7 @@ int QAccessibleTree::rowCount() const { const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); Q_ASSERT(treeView); - return treeView->d_func()->viewItems.count(); + return treeView->d_func()->viewItems.size(); } int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const @@ -1024,7 +1024,7 @@ void QAccessibleTableCell::unselectCell() //one cell is selected it cannot be unselected by the user if ((selectionMode != QAbstractItemView::MultiSelection) && (selectionMode != QAbstractItemView::ExtendedSelection) - && (view->selectionModel()->selectedIndexes().count() <= 1)) + && (view->selectionModel()->selectedIndexes().size() <= 1)) return; view->selectionModel()->select(m_index, QItemSelectionModel::Deselect); diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index c193d60f10..93e4b0554d 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -44,7 +44,7 @@ QMenu *QAccessibleMenu::menu() const int QAccessibleMenu::childCount() const { - return menu()->actions().count(); + return menu()->actions().size(); } QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const @@ -123,7 +123,7 @@ QMenuBar *QAccessibleMenuBar::menuBar() const int QAccessibleMenuBar::childCount() const { - return menuBar()->actions().count(); + return menuBar()->actions().size(); } QAccessibleInterface *QAccessibleMenuBar::child(int index) const diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 01bdfc1ea2..13f7eca898 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -87,7 +87,7 @@ static qsizetype qt_accAmpIndex(const QString &text) qsizetype fa = 0; while ((fa = text.indexOf(u'&', fa)) != -1) { ++fa; - if (fa < text.length()) { + if (fa < text.size()) { // ignore "&&" if (text.at(fa) == u'&') { @@ -299,14 +299,14 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel if (match & QAccessible::Controlled) { QObjectList allReceivers; QObject *connectionObject = object(); - for (int sig = 0; sig < d->primarySignals.count(); ++sig) { + for (int sig = 0; sig < d->primarySignals.size(); ++sig) { const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1()); allReceivers += receivers; } allReceivers.removeAll(object()); //### The object might connect to itself internally - for (int i = 0; i < allReceivers.count(); ++i) { + for (int i = 0; i < allReceivers.size(); ++i) { const QAccessible::Relation rel = QAccessible::Controlled; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i)); if (iface) diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 312204e8db..7a3fd464ce 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -359,7 +359,7 @@ QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) int QAccessibleMdiArea::childCount() const { - return mdiArea()->subWindowList().count(); + return mdiArea()->subWindowList().size(); } QAccessibleInterface *QAccessibleMdiArea::child(int index) const @@ -1072,7 +1072,7 @@ QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) QAccessibleInterface *QAccessibleMainWindow::child(int index) const { QList<QWidget*> kids = childWidgets(mainWindow()); - if (index >= 0 && index < kids.count()) { + if (index >= 0 && index < kids.size()) { return QAccessible::queryAccessibleInterface(kids.at(index)); } return nullptr; @@ -1081,7 +1081,7 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const int QAccessibleMainWindow::childCount() const { QList<QWidget*> kids = childWidgets(mainWindow()); - return kids.count(); + return kids.size(); } int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index bb0f8401d3..d3ed74979b 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -673,7 +673,7 @@ QString QAccessibleLineEdit::text(QAccessible::Text t) const if (lineEdit()->echoMode() == QLineEdit::Normal) str = lineEdit()->text(); else if (lineEdit()->echoMode() != QLineEdit::NoEcho) - str = QString(lineEdit()->text().length(), QChar::fromLatin1('*')); + str = QString(lineEdit()->text().size(), QChar::fromLatin1('*')); break; default: break; @@ -779,7 +779,7 @@ void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *e return; *startOffset = lineEdit()->selectionStart(); - *endOffset = *startOffset + lineEdit()->selectedText().length(); + *endOffset = *startOffset + lineEdit()->selectedText().size(); } QString QAccessibleLineEdit::text(int startOffset, int endOffset) const @@ -852,7 +852,7 @@ void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int int QAccessibleLineEdit::characterCount() const { - return lineEdit()->text().length(); + return lineEdit()->text().size(); } void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 3f4deaac1e..3e4b1d01c9 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -652,7 +652,7 @@ void QFileDialogPrivate::retranslateStrings() if (proxyModel) abstractModel = proxyModel; #endif - int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); + int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1); for (int i = 1; i < total; ++i) { actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); } @@ -673,7 +673,7 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files) { Q_Q(QFileDialog); emit q->filesSelected(files); - if (files.count() == 1) + if (files.size() == 1) emit q->fileSelected(files.first()); } @@ -1357,7 +1357,7 @@ QStringList qt_strip_filters(const QStringList &filters) #if QT_CONFIG(regularexpression) QStringList strippedFilters; static const QRegularExpression r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp)); - const int numFilters = filters.count(); + const int numFilters = filters.size(); strippedFilters.reserve(numFilters); for (int i = 0; i < numFilters; ++i) { QString filterName; @@ -1396,7 +1396,7 @@ void QFileDialog::setNameFilters(const QStringList &filters) { Q_D(QFileDialog); QStringList cleanedFilters; - const int numFilters = filters.count(); + const int numFilters = filters.size(); cleanedFilters.reserve(numFilters); for (int i = 0; i < numFilters; ++i) { cleanedFilters << filters[i].simplified(); @@ -2681,7 +2681,7 @@ void QFileDialog::accept() if (urls.isEmpty()) return; d->_q_emitUrlsSelected(urls); - if (urls.count() == 1) + if (urls.size() == 1) d->_q_emitUrlSelected(urls.first()); QDialog::accept(); return; @@ -2731,7 +2731,7 @@ void QFileDialog::accept() if (!info.exists()) { int maxNameLength = d->maxNameLength(info.path()); - if (maxNameLength >= 0 && info.fileName().length() > maxNameLength) + if (maxNameLength >= 0 && info.fileName().size() > maxNameLength) return; } @@ -2852,8 +2852,8 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo if (!qFileDialogUi->splitter->restoreState(splitterState)) return false; QList<int> list = qFileDialogUi->splitter->sizes(); - if (list.count() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) { - for (int i = 0; i < list.count(); ++i) + if (list.size() >= 2 && (list.at(0) == 0 || list.at(1) == 0)) { + for (int i = 0; i < list.size(); ++i) list[i] = qFileDialogUi->splitter->widget(i)->sizeHint().width(); qFileDialogUi->splitter->setSizes(list); } @@ -2876,7 +2876,7 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo if (proxyModel) abstractModel = proxyModel; #endif - int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); + int total = qMin(abstractModel->columnCount(QModelIndex()), actions.size() + 1); for (int i = 1; i < total; ++i) actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i)); @@ -3332,7 +3332,7 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation).path != newNativePath) { if (currentHistoryLocation >= 0) saveHistorySelection(); - while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) { + while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.size()) { currentHistory.removeLast(); } currentHistory.append({newNativePath, PersistentModelIndexList()}); @@ -3538,7 +3538,7 @@ void QFileDialogPrivate::_q_deleteCurrent() return; QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); - for (int i = list.count() - 1; i >= 0; --i) { + for (int i = list.size() - 1; i >= 0; --i) { QPersistentModelIndex index = list.at(i); if (index == qFileDialogUi->listView->rootIndex()) continue; @@ -3594,7 +3594,7 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) } const QStringList multipleFiles = typedFiles(); - if (multipleFiles.count() > 0) { + if (multipleFiles.size() > 0) { QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows(); QList<QModelIndex> newFiles; for (const auto &file : multipleFiles) { @@ -3661,7 +3661,7 @@ void QFileDialogPrivate::_q_updateOkButton() fileDir = info.canonicalFilePath(); } else { fileDir = fn.mid(0, fn.lastIndexOf(u'/')); - fileName = fn.mid(fileDir.length() + 1); + fileName = fn.mid(fileDir.size() + 1); } if (lineEditText.contains(".."_L1)) { fileDir = info.canonicalFilePath(); @@ -3679,7 +3679,7 @@ void QFileDialogPrivate::_q_updateOkButton() } if (!idx.isValid()) { int maxLength = maxNameLength(fileDir); - enableButton = maxLength < 0 || fileName.length() <= maxLength; + enableButton = maxLength < 0 || fileName.size() <= maxLength; } break; } @@ -3802,14 +3802,14 @@ void QFileDialogPrivate::_q_useNameFilter(int index) QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter); if (q_func()->acceptMode() == QFileDialog::AcceptSave) { QString newNameFilterExtension; - if (newNameFilters.count() > 0) + if (newNameFilters.size() > 0) newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); QString fileName = lineEdit()->text(); const QString fileNameExtension = QFileInfo(fileName).suffix(); if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) { - const int fileNameExtensionLength = fileNameExtension.length(); - fileName.replace(fileName.length() - fileNameExtensionLength, + const int fileNameExtensionLength = fileNameExtension.size(); + fileName.replace(fileName.size() - fileNameExtensionLength, fileNameExtensionLength, newNameFilterExtension); qFileDialogUi->listView->clearSelection(); lineEdit()->setText(fileName); @@ -3837,8 +3837,8 @@ void QFileDialogPrivate::_q_selectionChanged() continue; allFiles.append(index.data().toString()); } - if (allFiles.count() > 1) - for (qsizetype i = 0; i < allFiles.count(); ++i) { + if (allFiles.size() > 1) + for (qsizetype i = 0; i < allFiles.size(); ++i) { allFiles.replace(i, QString(u'"' + allFiles.at(i) + u'"')); } @@ -4006,12 +4006,12 @@ void QFileDialogComboBox::showPopup() // append history QList<QUrl> urls; - for (int i = 0; i < m_history.count(); ++i) { + for (int i = 0; i < m_history.size(); ++i) { QUrl path = QUrl::fromLocalFile(m_history.at(i)); if (!urls.contains(path)) urls.prepend(path); } - if (urls.count() > 0) { + if (urls.size() > 0) { model()->insertRow(model()->rowCount()); idx = model()->index(model()->rowCount()-1, 0); // ### TODO maybe add a horizontal line before this @@ -4157,12 +4157,12 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) { #if defined(Q_OS_UNIX) if (currentLocation == QDir::separator()) - return path.mid(currentLocation.length()); + return path.mid(currentLocation.size()); #endif if (currentLocation.endsWith(u'/')) - return path.mid(currentLocation.length()); + return path.mid(currentLocation.size()); else - return path.mid(currentLocation.length()+1); + return path.mid(currentLocation.size()+1); } return index.data(QFileSystemModel::FilePathRole).toString(); } @@ -4214,7 +4214,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const #else bool startsFromRoot = pathCopy[0] == sep; #endif - if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) { + if (parts.size() == 1 || (parts.size() > 1 && !startsFromRoot)) { const QFileSystemModel *dirModel; if (proxyModel) dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); @@ -4227,7 +4227,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const #endif if (currentLocation.contains(sep) && path != currentLocation) { QStringList currentLocationList = splitPath(currentLocation); - while (!currentLocationList.isEmpty() && parts.count() > 0 && parts.at(0) == ".."_L1) { + while (!currentLocationList.isEmpty() && parts.size() > 0 && parts.at(0) == ".."_L1) { parts.removeFirst(); currentLocationList.removeLast(); } diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index e9682440c6..7ef8ef8685 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1031,14 +1031,14 @@ void QMessageBoxPrivate::detectEscapeButton() // If there is only one button, make it the escape button const QList<QAbstractButton *> buttons = buttonBox->buttons(); - if (buttons.count() == 1) { + if (buttons.size() == 1) { detectedEscapeButton = buttons.first(); return; } // If there are two buttons and one of them is the "Show Details..." // button, then make the other one the escape button - if (buttons.count() == 2 && detailsButton) { + if (buttons.size() == 2 && detailsButton) { auto idx = buttons.indexOf(detailsButton); if (idx != -1) { detectedEscapeButton = buttons.at(1 - idx); diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index bbbcb83630..8fb160ab65 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -211,7 +211,7 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move) if (row == -1) row = rowCount(); row = qMin(row, rowCount()); - for (int i = list.count() - 1; i >= 0; --i) { + for (int i = list.size() - 1; i >= 0; --i) { QUrl url = list.at(i); if (!url.isValid() || url.scheme() != "file"_L1) continue; @@ -291,7 +291,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model) void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { QModelIndex parent = topLeft.parent(); - for (int i = 0; i < watching.count(); ++i) { + for (int i = 0; i < watching.size(); ++i) { QModelIndex index = watching.at(i).index; if (index.model() && topLeft.model()) { Q_ASSERT(index.model() == topLeft.model()); @@ -312,7 +312,7 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto void QUrlModel::layoutChanged() { QStringList paths; - const int numPaths = watching.count(); + const int numPaths = watching.size(); paths.reserve(numPaths); for (int i = 0; i < numPaths; ++i) paths.append(watching.at(i).path); @@ -417,7 +417,7 @@ void QSidebar::showContextMenu(const QPoint &position) connect(action, SIGNAL(triggered()), this, SLOT(removeEntry())); actions.append(action); } - if (actions.count() > 0) + if (actions.size() > 0) QMenu::exec(actions, mapToGlobal(position)); } #endif // QT_CONFIG(menu) @@ -431,7 +431,7 @@ void QSidebar::removeEntry() { QList<QModelIndex> idxs = selectionModel()->selectedIndexes(); QList<QPersistentModelIndex> indexes; - const int numIndexes = idxs.count(); + const int numIndexes = idxs.size(); indexes.reserve(numIndexes); for (int i = 0; i < numIndexes; i++) indexes.append(idxs.at(i)); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 5b95b62772..2a0cdb59ef 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -181,7 +181,7 @@ QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *obje void QWizardField::resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable) { if (property.isEmpty()) - findProperty(defaultPropertyTable.constData(), defaultPropertyTable.count()); + findProperty(defaultPropertyTable.constData(), defaultPropertyTable.size()); initialValue = object->property(property); } @@ -695,7 +695,7 @@ void QWizardPrivate::reset() if (current != -1) { q->currentPage()->hide(); cleanupPagesNotInHistory(); - for (int i = history.count() - 1; i >= 0; --i) + for (int i = history.size() - 1; i >= 0; --i) q->cleanupPage(history.at(i)); history.clear(); for (QWizardPage *page : qAsConst(pageMap)) @@ -732,7 +732,7 @@ void QWizardPrivate::addField(const QWizardField &field) return; } - fieldIndexMap.insert(myField.name, fields.count()); + fieldIndexMap.insert(myField.name, fields.size()); fields += myField; if (myField.mandatory && !myField.changedSignal.isEmpty()) QObject::connect(myField.object, myField.changedSignal, @@ -1425,10 +1425,10 @@ void QWizardPrivate::updateButtonTexts() void QWizardPrivate::updateButtonLayout() { if (buttonsHaveCustomLayout) { - QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array(buttonsCustomLayout.count()); - for (int i = 0; i < buttonsCustomLayout.count(); ++i) + QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array(buttonsCustomLayout.size()); + for (int i = 0; i < buttonsCustomLayout.size(); ++i) array[i] = buttonsCustomLayout.at(i); - setButtonLayout(array.constData(), array.count()); + setButtonLayout(array.constData(), array.size()); } else { // Positions: // Help Stretch Custom1 Custom2 Custom3 Cancel Back Next Commit Finish Cancel Help @@ -1645,15 +1645,15 @@ void QWizardPrivate::_q_updateButtonStates() const QWizardPage *page = q->currentPage(); bool complete = page && page->isComplete(); - btn.back->setEnabled(history.count() > 1 - && !q->page(history.at(history.count() - 2))->isCommitPage() + btn.back->setEnabled(history.size() > 1 + && !q->page(history.at(history.size() - 2))->isCommitPage() && (!canFinish || !(opts & QWizard::DisabledBackButtonOnLastPage))); btn.next->setEnabled(canContinue && complete); btn.commit->setEnabled(canContinue && complete); btn.finish->setEnabled(canFinish && complete); const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton) - && (history.count() > 1 || !(opts & QWizard::NoBackButtonOnStartPage)) + && (history.size() > 1 || !(opts & QWizard::NoBackButtonOnStartPage)) && (canContinue || !(opts & QWizard::NoBackButtonOnLastPage)); bool commitPage = page && page->isCommitPage(); btn.back->setVisible(backButtonVisible); @@ -2228,7 +2228,7 @@ void QWizard::setPage(int theid, QWizardPage *page) page->setParent(d->pageFrame); QList<QWizardField> &pendingFields = page->d_func()->pendingFields; - for (int i = 0; i < pendingFields.count(); ++i) + for (int i = 0; i < pendingFields.size(); ++i) d->addField(pendingFields.at(i)); pendingFields.clear(); @@ -2269,11 +2269,11 @@ void QWizard::removePage(int id) QWizardPage *removedPage = nullptr; // update startItem accordingly - if (d->pageMap.count() > 0) { // only if we have any pages + if (d->pageMap.size() > 0) { // only if we have any pages if (d->start == id) { const int firstId = d->pageMap.constBegin().key(); if (firstId == id) { - if (d->pageMap.count() > 1) + if (d->pageMap.size() > 1) d->start = (++d->pageMap.constBegin()).key(); // secondId else d->start = -1; // removing the last page @@ -2296,7 +2296,7 @@ void QWizard::removePage(int id) removedPage = d->pageMap.take(id); d->history.removeOne(id); d->_q_updateButtonStates(); - } else if (d->history.count() == 1) { + } else if (d->history.size() == 1) { // Case 3: removing the current page which is the first (and only) one in the history d->reset(); removedPage = d->pageMap.take(id); @@ -2319,7 +2319,7 @@ void QWizard::removePage(int id) d->pageVBoxLayout->removeWidget(removedPage); - for (int i = d->fields.count() - 1; i >= 0; --i) { + for (int i = d->fields.size() - 1; i >= 0; --i) { if (d->fields.at(i).page == removedPage) { removedPage->d_func()->pendingFields += d->fields.at(i); d->removeFieldAt(i); @@ -2397,7 +2397,7 @@ void QWizard::setStartId(int theid) Q_D(QWizard); int newStart = theid; if (theid == -1) - newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1; + newStart = d->pageMap.size() ? d->pageMap.constBegin().key() : -1; if (d->start == newStart) { d->startSetByUser = theid != -1; @@ -2706,7 +2706,7 @@ void QWizard::setButtonLayout(const QList<WizardButton> &layout) { Q_D(QWizard); - for (int i = 0; i < layout.count(); ++i) { + for (int i = 0; i < layout.size(); ++i) { WizardButton button1 = layout.at(i); if (button1 == NoButton || button1 == Stretch) @@ -2891,7 +2891,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property, const char *changedSignal) { Q_D(QWizard); - for (int i = d->defaultPropertyTable.count() - 1; i >= 0; --i) { + for (int i = d->defaultPropertyTable.size() - 1; i >= 0; --i) { if (qstrcmp(d->defaultPropertyTable.at(i).className, className) == 0) { d->defaultPropertyTable.remove(i); break; @@ -3071,7 +3071,7 @@ QSize QWizard::sizeHint() const void QWizard::back() { Q_D(QWizard); - int n = d->history.count() - 2; + int n = d->history.size() - 2; if (n < 0) return; d->switchToPage(d->history.at(n), QWizardPrivate::Backward); @@ -3670,7 +3670,7 @@ bool QWizardPage::isComplete() const return true; const QList<QWizardField> &wizardFields = d->wizard->d_func()->fields; - for (int i = wizardFields.count() - 1; i >= 0; --i) { + for (int i = wizardFields.size() - 1; i >= 0; --i) { const QWizardField &field = wizardFields.at(i); if (field.page == this && field.mandatory) { QVariant value = field.object->property(field.property); diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 16286e47bf..5cd15f5386 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -459,7 +459,7 @@ void SequentialAnchorData::updateChildrenSizes() // "from" or "to", that _contains_ one of them. AnchorVertex *prev = from; - for (int i = 0; i < m_edges.count(); ++i) { + for (int i = 0; i < m_edges.size(); ++i) { AnchorData *e = m_edges.at(i); const bool edgeIsForward = (e->from == prev); @@ -496,7 +496,7 @@ void SequentialAnchorData::calculateSizeHints() AnchorVertex *prev = from; - for (int i = 0; i < m_edges.count(); ++i) { + for (int i = 0; i < m_edges.size(); ++i) { AnchorData *edge = m_edges.at(i); const bool edgeIsForward = (edge->from == prev); @@ -664,7 +664,7 @@ AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *new parallel->isCenterAnchor = true; - for (int j = 0; j < constraints.count(); ++j) { + for (int j = 0; j < constraints.size(); ++j) { QSimplexConstraint *c = constraints[j]; if (c->variables.contains(child)) { childConstraints->append(c); @@ -710,9 +710,9 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph, Anchor AnchorVertex *prev = before; QList<AnchorData *> edges; - edges.reserve(vertices.count() + 1); + edges.reserve(vertices.size() + 1); - const int numVertices = vertices.count(); + const int numVertices = vertices.size(); edges.reserve(numVertices + 1); // Take from the graph, the edges that will be simplificated for (int i = 0; i < numVertices; ++i) { @@ -838,7 +838,7 @@ bool QGraphicsAnchorLayoutPrivate::replaceVertex(Qt::Orientation orientation, An Graph<AnchorVertex, AnchorData> &g = graph[orientation]; bool feasible = true; - for (int i = 0; i < edges.count(); ++i) { + for (int i = 0; i < edges.size(); ++i) { AnchorData *ad = edges[i]; AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV); @@ -886,7 +886,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) QList<AnchorVertex *> adjacents = g.adjacentVertices(v); int index = 0; - while (index < adjacents.count()) { + while (index < adjacents.size()) { AnchorVertex *next = adjacents.at(index); index++; @@ -906,7 +906,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v); const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next); - for (int i = 0; i < vAdjacents.count(); ++i) { + for (int i = 0; i < vAdjacents.size(); ++i) { AnchorVertex *adjacent = vAdjacents.at(i); if (adjacent != next) { AnchorData *ad = g.edgeData(v, adjacent); @@ -914,7 +914,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) } } - for (int i = 0; i < nextAdjacents.count(); ++i) { + for (int i = 0; i < nextAdjacents.size(); ++i) { AnchorVertex *adjacent = nextAdjacents.at(i); if (adjacent != v) { AnchorData *ad = g.edgeData(next, adjacent); @@ -1017,7 +1017,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient // // Identifies cases (a) and (b) - endOfSequence = isLayoutVertex || adjacents.count() != 2; + endOfSequence = isLayoutVertex || adjacents.size() != 2; if (!endOfSequence) { // This is a tricky part. We peek at the next vertex to find out whether @@ -1059,7 +1059,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient // // Add next non-visited vertices to the stack. // - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { AnchorVertex *next = adjacents.at(i); if (visited.contains(next)) continue; @@ -1098,7 +1098,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient const AnchorData *lastAnchor = g.edgeData(candidates.constLast(), afterSequence); if (lastAnchor->isCenterAnchor) { afterSequence = candidates.constLast(); - candidates.remove(candidates.count() - 1); + candidates.remove(candidates.size() - 1); if (candidates.isEmpty()) continue; @@ -1153,7 +1153,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) } else if (edge->type == AnchorData::Sequential) { SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge); - for (int i = 0; i < sequence->m_edges.count(); ++i) { + for (int i = 0; i < sequence->m_edges.size(); ++i) { AnchorData *data = sequence->m_edges.at(i); restoreSimplifiedAnchor(data); } @@ -1188,7 +1188,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa if (!parallel->isCenterAnchor) return; - for (int i = 0; i < parallel->m_firstConstraints.count(); ++i) { + for (int i = 0; i < parallel->m_firstConstraints.size(); ++i) { QSimplexConstraint *c = parallel->m_firstConstraints.at(i); qreal v = c->variables[parallel]; c->variables.remove(parallel); @@ -1199,7 +1199,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa // addAnchorMaybeParallel(). const bool needsReverse = !parallel->secondForward(); - for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) { + for (int i = 0; i < parallel->m_secondConstraints.size(); ++i) { QSimplexConstraint *c = parallel->m_secondConstraints.at(i); qreal v = c->variables[parallel]; if (needsReverse) @@ -1219,7 +1219,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Qt::Orientation orient // Restore anchor simplification Graph<AnchorVertex, AnchorData> &g = graph[orientation]; QList<QPair<AnchorVertex *, AnchorVertex *>> connections = g.connections(); - for (int i = 0; i < connections.count(); ++i) { + for (int i = 0; i < connections.size(); ++i) { AnchorVertex *v1 = connections.at(i).first; AnchorVertex *v2 = connections.at(i).second; AnchorData *edge = g.edgeData(v1, v2); @@ -1255,14 +1255,14 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) // In the next step, we'll change the anchors vertices so that would not be possible anymore. QList<AnchorData *> ¶llelAnchors = anchorsFromSimplifiedVertices[orientation]; - for (int i = parallelAnchors.count() - 1; i >= 0; --i) { + for (int i = parallelAnchors.size() - 1; i >= 0; --i) { ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i)); restoreSimplifiedConstraints(parallel); } // Then, we will restore the vertices in the inverse order of creation, this way we ensure that // the vertex being restored was not wrapped by another simplification. - for (int i = toRestore.count() - 1; i >= 0; --i) { + for (int i = toRestore.size() - 1; i >= 0; --i) { AnchorVertexPair *pair = toRestore.at(i); QList<AnchorVertex *> adjacents = g.adjacentVertices(pair); @@ -1273,7 +1273,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) g.createEdge(first, second, pair->m_removedAnchor); // Restore the anchors for the first child vertex - for (int j = 0; j < pair->m_firstAnchors.count(); ++j) { + for (int j = 0; j < pair->m_firstAnchors.size(); ++j) { AnchorData *ad = pair->m_firstAnchors.at(j); Q_ASSERT(ad->from == pair || ad->to == pair); @@ -1282,7 +1282,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) } // Restore the anchors for the second child vertex - for (int j = 0; j < pair->m_secondAnchors.count(); ++j) { + for (int j = 0; j < pair->m_secondAnchors.size(); ++j) { AnchorData *ad = pair->m_secondAnchors.at(j); Q_ASSERT(ad->from == pair || ad->to == pair); @@ -1290,7 +1290,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) g.createEdge(ad->from, ad->to, ad); } - for (int j = 0; j < adjacents.count(); ++j) { + for (int j = 0; j < adjacents.size(); ++j) { g.takeEdge(pair, adjacents.at(j)); } @@ -1500,7 +1500,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( AnchorData *oldData = g.edgeData(first, center); // Remove center constraint - for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0; --i) { + for (int i = itemCenterConstraints[orientation].size() - 1; i >= 0; --i) { if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)) { delete itemCenterConstraints[orientation].takeAt(i); break; @@ -1521,7 +1521,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( // this is only called from removeAnchors() // first, remove all non-internal anchors QList<AnchorVertex*> adjacents = g.adjacentVertices(center); - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { AnchorVertex *v = adjacents.at(i); if (v->m_item != item) { removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge)); @@ -2014,7 +2014,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs() QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints) { QSet<AnchorData *> variableSet; - for (int i = 0; i < constraints.count(); ++i) { + for (int i = 0; i < constraints.size(); ++i) { const QSimplexConstraint *c = constraints.at(i); for (auto it = c->variables.cbegin(), end = c->variables.cend(); it != end; ++it) variableSet.insert(static_cast<AnchorData *>(it.key())); @@ -2129,7 +2129,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(Qt::Orientation orientation) */ static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount) { - for (int i = 0; i < constraints.count(); ++i) { + for (int i = 0; i < constraints.size(); ++i) { QSimplexConstraint *c = constraints.at(i); const qreal multiplier = std::accumulate(c->variables.cbegin(), c->variables.cend(), qreal(0)); c->constant += multiplier * amount; @@ -2187,8 +2187,8 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Qt::Orientation orientation, c } else { // No Simplex is necessary because the path was simplified all the way to a single // anchor. - Q_ASSERT(path.positives.count() == 1); - Q_ASSERT(path.negatives.count() == 0); + Q_ASSERT(path.positives.size() == 1); + Q_ASSERT(path.negatives.size() == 0); AnchorData *ad = *path.positives.cbegin(); ad->sizeAtMinimum = ad->minSize; @@ -2219,7 +2219,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstra if (feasible) { // Propagate size at preferred to other sizes. Semi-floats always will be // in their sizeAtPreferred. - for (int j = 0; j < variables.count(); ++j) { + for (int j = 0; j < variables.size(); ++j) { AnchorData *ad = variables.at(j); Q_ASSERT(ad); ad->sizeAtMinimum = ad->sizeAtPreferred; @@ -2243,7 +2243,7 @@ void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientati QList<QPair<AnchorVertex *, AnchorVertex *>> vertices = g.connections(); QLayoutStyleInfo styleInf = styleInfo(); - for (int i = 0; i < vertices.count(); ++i) { + for (int i = 0; i < vertices.size(); ++i) { AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second); data->refreshSizeHints(&styleInf); } @@ -2335,7 +2335,7 @@ void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Qt::Orientation orientation Graph<AnchorVertex, AnchorData> &g = graph[orientation]; const QList<QPair<AnchorVertex *, AnchorVertex *>> &vertices = g.connections(); - for (int i = 0; i < vertices.count(); ++i) { + for (int i = 0; i < vertices.size(); ++i) { AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second); ad->updateChildrenSizes(); } @@ -2657,7 +2657,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie interpolateEdge(pair.first, edge); QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second); - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { if (!visited.contains(adjacents.at(i))) queue.enqueue(qMakePair(pair.second, adjacents.at(i))); } @@ -2741,7 +2741,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter) objective.variables.insert(*iter, -1.0); - const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset; + const qreal objectiveOffset = (path.positives.size() - path.negatives.size()) * g_offset; simplex.setObjective(&objective); // Calculate minimum values diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h index 06a2de1ea8..f3b2ec3731 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h @@ -83,7 +83,7 @@ public: int indexOf(QGraphicsLayoutItem *item) const { - for (int i = 0; i < q_items.count(); ++i) { + for (int i = 0; i < q_items.size(); ++i) { if (item == static_cast<QGraphicsGridLayoutEngineItem*>(q_items.at(i))->layoutItem()) return i; } diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 9008b54d84..02a24f99fa 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -2175,7 +2175,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this) return false; - for (int i = 0; i < scene_d->modalPanels.count(); ++i) { + for (int i = 0; i < scene_d->modalPanels.size(); ++i) { QGraphicsItem *modalPanel = scene_d->modalPanels.at(i); if (modalPanel->panelModality() == QGraphicsItem::SceneModal) { // Scene modal panels block all non-descendents. @@ -7665,13 +7665,13 @@ void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObj int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - return d->children.count(); + return d->children.size(); } QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - if (index >= 0 && index < d->children.count()) + if (index >= 0 && index < d->children.size()) return d->children.at(index)->toGraphicsObject(); else return nullptr; @@ -7680,7 +7680,7 @@ QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGra void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - int childCount = d->children.count(); + int childCount = d->children.size(); if (d->sendParentChangeNotification) { for (int index = 0; index < childCount; index++) d->children.at(0)->setParentItem(nullptr); @@ -10749,7 +10749,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic } else { QTextLayout::FormatRange range; range.start = 0; - range.length = layout.text().length(); + range.length = layout.text().size(); range.format.setTextOutline(d->pen); layout.setFormats(QList<QTextLayout::FormatRange>(1, range)); } diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 061ebce31b..84bcb661a3 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -411,7 +411,7 @@ void QGraphicsScenePrivate::_q_polishItems() const QVariant booleanTrueVariant(true); QGraphicsItem *item = nullptr; QGraphicsItemPrivate *itemd = nullptr; - const int oldUnpolishedCount = unpolishedItems.count(); + const int oldUnpolishedCount = unpolishedItems.size(); for (int i = 0; i < oldUnpolishedCount; ++i) { item = unpolishedItems.at(i); @@ -429,7 +429,7 @@ void QGraphicsScenePrivate::_q_polishItems() } } - if (unpolishedItems.count() == oldUnpolishedCount) { + if (unpolishedItems.size() == oldUnpolishedCount) { // No new items were added to the vector. unpolishedItems.clear(); } else { diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 7bbe5d1608..d3ea1e5b40 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -2413,7 +2413,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const { QPolygonF poly; - poly.reserve(polygon.count()); + poly.reserve(polygon.size()); for (const QPoint &point : polygon) poly << mapToScene(point); return poly; @@ -2509,7 +2509,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const { QPolygon poly; - poly.reserve(polygon.count()); + poly.reserve(polygon.size()); for (const QPointF &point : polygon) poly << mapFromScene(point); return poly; @@ -2623,7 +2623,7 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects) // Extract and reset dirty scene rect info. QList<QRect> dirtyViewportRects; - dirtyViewportRects.reserve(d->dirtyRegion.rectCount() + rects.count()); + dirtyViewportRects.reserve(d->dirtyRegion.rectCount() + rects.size()); for (const QRect &dirtyRect : d->dirtyRegion) dirtyViewportRects += dirtyRect; d->dirtyRegion = QRegion(); diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index f80fc4e4e4..a253dcebb3 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1968,7 +1968,7 @@ void QGraphicsWidget::addAction(QAction *action) */ void QGraphicsWidget::addActions(const QList<QAction *> &actions) { - for (int i = 0; i < actions.count(); ++i) + for (int i = 0; i < actions.size(); ++i) insertAction(nullptr, actions.at(i)); } @@ -2025,7 +2025,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) */ void QGraphicsWidget::insertActions(QAction *before, const QList<QAction *> &actions) { - for (int i = 0; i < actions.count(); ++i) + for (int i = 0; i < actions.size(); ++i) insertAction(before, actions.at(i)); } diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index 23f63909a5..948437bf68 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -580,7 +580,7 @@ bool QSimplex::simplifyConstraints(QList<QSimplexConstraint *> *constraints) QList<QSimplexConstraint *>::iterator iter = constraints->begin(); while (iter != constraints->end()) { QSimplexConstraint *c = *iter; - if ((c->ratio == QSimplexConstraint::Equal) && (c->variables.count() == 1)) { + if ((c->ratio == QSimplexConstraint::Equal) && (c->variables.size() == 1)) { // Check whether this is a constraint of type Var == K // If so, save its value to "results". QSimplexVariable *variable = c->variables.constBegin().key(); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 57139cce61..7a7b5c4753 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2829,10 +2829,10 @@ void QAbstractItemView::updateEditorGeometries() //we hide and release the editor outside of the loop because it might change the focus and try //to change the editors hashes. - for (int i = 0; i < editorsToHide.count(); ++i) { + for (int i = 0; i < editorsToHide.size(); ++i) { editorsToHide.at(i)->hide(); } - for (int i = 0; i < editorsToRelease.count(); ++i) { + for (int i = 0; i < editorsToRelease.size(); ++i) { d->releaseEditor(editorsToRelease.at(i)); } } @@ -3053,9 +3053,9 @@ void QAbstractItemView::keyboardSearch(const QString &search) // special case for searches with same key like 'aaaaa' bool sameKey = false; - if (d->keyboardInput.length() > 1) { - int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); - sameKey = (c == d->keyboardInput.length()); + if (d->keyboardInput.size() > 1) { + int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.size() - 1)); + sameKey = (c == d->keyboardInput.size()); if (sameKey) skipRow = true; } @@ -3793,7 +3793,7 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions) { Q_D(QAbstractItemView); QModelIndexList indexes = d->selectedDraggableIndexes(); - if (indexes.count() > 0) { + if (indexes.size() > 0) { QMimeData *data = d->model->mimeData(indexes); if (!data) return; @@ -4636,7 +4636,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, QStyleOptionViewItem option; q->initViewItemOption(&option); option.state |= QStyle::State_Selected; - for (int j = 0; j < paintPairs.count(); ++j) { + for (int j = 0; j < paintPairs.size(); ++j) { option.rect = paintPairs.at(j).rect.translated(-r->topLeft()); const QModelIndex ¤t = paintPairs.at(j).index; adjustViewOptionsForIndex(&option, current); diff --git a/src/widgets/itemviews/qbsptree.cpp b/src/widgets/itemviews/qbsptree.cpp index 13660ee3d9..d75144b1a8 100644 --- a/src/widgets/itemviews/qbsptree.cpp +++ b/src/widgets/itemviews/qbsptree.cpp @@ -40,9 +40,9 @@ void QBspTree::climbTree(const QRect &rect, callback *function, QBspTreeData dat void QBspTree::climbTree(const QRect &area, callback *function, QBspTreeData data, int index) { - if (index >= nodes.count()) { // the index points to a leaf + if (index >= nodes.size()) { // the index points to a leaf Q_ASSERT(!nodes.isEmpty()); - function(leaf(index - nodes.count()), area, visited, data); + function(leaf(index - nodes.size()), area, visited, data); return; } diff --git a/src/widgets/itemviews/qbsptree_p.h b/src/widgets/itemviews/qbsptree_p.h index 83d9055aad..1f00616e87 100644 --- a/src/widgets/itemviews/qbsptree_p.h +++ b/src/widgets/itemviews/qbsptree_p.h @@ -55,7 +55,7 @@ public: void climbTree(const QRect &rect, callback *function, QBspTreeData data); - inline int leafCount() const { return leaves.count(); } + inline int leafCount() const { return leaves.size(); } inline QList<int> &leaf(int i) { return leaves[i]; } inline void insertLeaf(const QRect &r, int i) { climbTree(r, &insert, i, 0); } inline void removeLeaf(const QRect &r, int i) { climbTree(r, &remove, i, 0); } diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 73748d3af4..040bddb311 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -98,7 +98,7 @@ void QColumnView::setResizeGripsVisible(bool visible) if (d->showResizeGrips == visible) return; d->showResizeGrips = visible; - for (int i = 0; i < d->columns.count(); ++i) { + for (int i = 0; i < d->columns.size(); ++i) { QAbstractItemView *view = d->columns[i]; if (visible) { QColumnViewGrip *grip = new QColumnViewGrip(view); @@ -140,7 +140,7 @@ void QColumnView::setRootIndex(const QModelIndex &index) return; d->closeColumns(); - Q_ASSERT(d->columns.count() == 0); + Q_ASSERT(d->columns.size() == 0); QAbstractItemView *view = d->createColumn(index, true); if (view->selectionModel()) @@ -206,7 +206,7 @@ void QColumnView::scrollContentsBy(int dx, int dy) return; dx = isRightToLeft() ? -dx : dx; - for (int i = 0; i < d->columns.count(); ++i) + for (int i = 0; i < d->columns.size(); ++i) d->columns.at(i)->move(d->columns.at(i)->x() + dx, 0); d->offset += dx; QAbstractItemView::scrollContentsBy(dx, dy); @@ -420,7 +420,7 @@ int QColumnView::verticalOffset() const */ QRegion QColumnView::visualRegionForSelection(const QItemSelection &selection) const { - int ranges = selection.count(); + int ranges = selection.size(); if (ranges == 0) return QRect(); @@ -603,7 +603,7 @@ void QColumnViewPrivate::_q_clicked(const QModelIndex &index) Q_Q(QColumnView); QModelIndex parent = index.parent(); QAbstractItemView *columnClicked = nullptr; - for (int column = 0; column < columns.count(); ++column) { + for (int column = 0; column < columns.size(); ++column) { if (columns.at(column)->rootIndex() == parent) { columnClicked = columns[column]; break; @@ -664,16 +664,16 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo q->connect(grip, SIGNAL(gripMoved(int)), q, SLOT(_q_gripMoved(int))); } - if (columnSizes.count() > columns.count()) { - view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); + if (columnSizes.size() > columns.size()) { + view->setGeometry(0, 0, columnSizes.at(columns.size()), viewport->height()); } else { int initialWidth = view->sizeHint().width(); if (q->isRightToLeft()) view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); else view->setGeometry(0, 0, initialWidth, viewport->height()); - columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); - columnSizes[columns.count()] = initialWidth; + columnSizes.resize(qMax(columnSizes.size(), columns.size() + 1)); + columnSizes[columns.size()] = initialWidth; } if (!columns.isEmpty() && columns.constLast()->isHidden()) columns.constLast()->setVisible(true); @@ -826,8 +826,8 @@ void QColumnView::setColumnWidths(const QList<int> &list) { Q_D(QColumnView); int i = 0; - const int listCount = list.count(); - const int count = qMin(listCount, d->columns.count()); + const int listCount = list.size(); + const int count = qMin(listCount, d->columns.size()); for (; i < count; ++i) { d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height()); d->columnSizes[i] = list.at(i); @@ -847,7 +847,7 @@ QList<int> QColumnView::columnWidths() const { Q_D(const QColumnView); QList<int> list; - const int columnCount = d->columns.count(); + const int columnCount = d->columns.size(); list.reserve(columnCount); for (int i = 0; i < columnCount; ++i) list.append(d->columnSizes.at(i)); @@ -984,9 +984,9 @@ void QColumnView::selectAll() QModelIndexList indexList = selectionModel()->selectedIndexes(); QModelIndex parent = rootIndex(); QItemSelection selection; - if (indexList.count() >= 1) + if (indexList.size() >= 1) parent = indexList.at(0).parent(); - if (indexList.count() == 1) { + if (indexList.size() == 1) { parent = indexList.at(0); if (!model()->hasChildren(parent)) parent = parent.parent(); @@ -1039,7 +1039,7 @@ void QColumnViewPrivate::checkColumnCreation(const QModelIndex &parent) if (parent == q_func()->currentIndex() && model->hasChildren(parent)) { //the parent has children and is the current //let's try to find out if there is already a mapping that is good - for (int i = 0; i < columns.count(); ++i) { + for (int i = 0; i < columns.size(); ++i) { QAbstractItemView *view = columns.at(i); if (view->rootIndex() == parent) { if (view == previewColumn) { diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index dfb60a91ec..589c382083 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -980,7 +980,7 @@ bool QHeaderView::isSectionHidden(int logicalIndex) const int QHeaderView::hiddenSectionCount() const { Q_D(const QHeaderView); - return d->hiddenSectionSize.count(); + return d->hiddenSectionSize.size(); } /*! @@ -1061,7 +1061,7 @@ int QHeaderView::visualIndex(int logicalIndex) const if (d->visualIndices.isEmpty()) { // nothing has been moved, so we have no mapping if (logicalIndex < d->sectionCount()) return logicalIndex; - } else if (logicalIndex < d->visualIndices.count()) { + } else if (logicalIndex < d->visualIndices.size()) { int visual = d->visualIndices.at(logicalIndex); Q_ASSERT(visual < d->sectionCount()); return visual; @@ -1911,10 +1911,10 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, QHeaderViewPrivate::SectionItem section(d->defaultSectionSize, d->globalResizeMode); d->sectionStartposRecalc = true; - if (d->sectionItems.isEmpty() || insertAt >= d->sectionItems.count()) { + if (d->sectionItems.isEmpty() || insertAt >= d->sectionItems.size()) { int insertLength = d->defaultSectionSize * insertCount; d->length += insertLength; - d->sectionItems.insert(d->sectionItems.count(), insertCount, section); // append + d->sectionItems.insert(d->sectionItems.size(), insertCount, section); // append } else { // separate them out into their own sections int insertLength = d->defaultSectionSize * insertCount; @@ -1937,8 +1937,8 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, // update mapping if (!d->visualIndices.isEmpty() && !d->logicalIndices.isEmpty()) { - Q_ASSERT(d->visualIndices.count() == d->logicalIndices.count()); - int mappingCount = d->visualIndices.count(); + Q_ASSERT(d->visualIndices.size() == d->logicalIndices.size()); + int mappingCount = d->visualIndices.size(); for (int i = 0; i < mappingCount; ++i) { if (d->visualIndices.at(i) >= logicalFirst) d->visualIndices[i] += insertCount; @@ -2028,7 +2028,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, if (logicalFirst == logicalLast) { // Remove just one index. int l = logicalFirst; int visual = visualIndices.at(l); - Q_ASSERT(sectionCount() == logicalIndices.count()); + Q_ASSERT(sectionCount() == logicalIndices.size()); for (int v = 0; v < sectionCount(); ++v) { if (v > visual) { int logical = logicalIndices.at(v); @@ -2043,17 +2043,17 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, removeSectionsFromSectionItems(visual, visual); } else { sectionStartposRecalc = true; // We will need to recalc positions after removing items - for (int u = 0; u < sectionItems.count(); ++u) // Store section info + for (int u = 0; u < sectionItems.size(); ++u) // Store section info sectionItems.at(u).tmpLogIdx = logicalIndices.at(u); - for (int v = sectionItems.count() - 1; v >= 0; --v) { // Remove the sections + for (int v = sectionItems.size() - 1; v >= 0; --v) { // Remove the sections if (logicalFirst <= sectionItems.at(v).tmpLogIdx && sectionItems.at(v).tmpLogIdx <= logicalLast) removeSectionsFromSectionItems(v, v); } - visualIndices.resize(sectionItems.count()); - logicalIndices.resize(sectionItems.count()); + visualIndices.resize(sectionItems.size()); + logicalIndices.resize(sectionItems.size()); int* visual_data = visualIndices.data(); int* logical_data = logicalIndices.data(); - for (int w = 0; w < sectionItems.count(); ++w) { // Restore visual and logical indexes + for (int w = 0; w < sectionItems.size(); ++w) { // Restore visual and logical indexes int logindex = sectionItems.at(w).tmpLogIdx; if (logindex > logicalFirst) logindex -= changeCount; @@ -2126,9 +2126,9 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged(const QList<QPersistentMode return; layoutChangePersistentSections.clear(); - layoutChangePersistentSections.reserve(std::min(10, int(sectionItems.count()))); + layoutChangePersistentSections.reserve(std::min(10, int(sectionItems.size()))); // after layoutChanged another section can be last stretched section - if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) { + if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.size()) { const int visual = visualIndex(lastSectionLogicalIdx); if (visual >= 0 && visual < sectionItems.size()) { auto &itemRef = sectionItems[visual]; @@ -2223,7 +2223,7 @@ void QHeaderViewPrivate::_q_sectionsChanged(const QList<QPersistentModelIndex> & : index.row()); // the new visualIndices are already adjusted / reset by initializeSections() const int newVisualIndex = visualIndex(newLogicalIndex); - if (newVisualIndex < sectionItems.count()) { + if (newVisualIndex < sectionItems.size()) { auto &newSection = sectionItems[newVisualIndex]; newSection = item.section; @@ -2288,7 +2288,7 @@ void QHeaderView::initializeSections(int start, int end) int newCount = end + 1; d->removeSectionsFromSectionItems(newCount, d->sectionCount() - 1); if (!d->hiddenSectionSize.isEmpty()) { - if (oldCount - newCount > d->hiddenSectionSize.count()) { + if (oldCount - newCount > d->hiddenSectionSize.size()) { for (int i = end + 1; i < d->sectionCount(); ++i) d->hiddenSectionSize.remove(i); } else { @@ -3453,7 +3453,7 @@ void QHeaderView::initStyleOption(QStyleOptionFrame *option) const bool QHeaderViewPrivate::isSectionSelected(int section) const { int i = section * 2; - if (i < 0 || i >= sectionSelected.count()) + if (i < 0 || i >= sectionSelected.size()) return false; if (sectionSelected.testBit(i)) // if the value was cached return sectionSelected.testBit(i + 1); @@ -3677,7 +3677,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool void QHeaderViewPrivate::createSectionItems(int start, int end, int sizePerSection, QHeaderView::ResizeMode mode) { - if (end >= sectionItems.count()) { + if (end >= sectionItems.size()) { sectionItems.resize(end + 1); sectionStartposRecalc = true; } @@ -3693,7 +3693,7 @@ void QHeaderViewPrivate::createSectionItems(int start, int end, int sizePerSecti void QHeaderViewPrivate::removeSectionsFromSectionItems(int start, int end) { // remove sections - sectionStartposRecalc |= (end != sectionItems.count() - 1); + sectionStartposRecalc |= (end != sectionItems.size() - 1); int removedlength = 0; for (int u = start; u <= end; ++u) removedlength += sectionItems.at(u).size; @@ -3881,7 +3881,7 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size) customDefaultSectionSize = true; if (state == QHeaderViewPrivate::ResizeSection) preventCursorChangeInSetOffset = true; - for (int i = 0; i < sectionItems.count(); ++i) { + for (int i = 0; i < sectionItems.size(); ++i) { QHeaderViewPrivate::SectionItem §ion = sectionItems[i]; if (hiddenSectionSize.isEmpty() || !isVisualIndexHidden(i)) { // resize on not hidden. const int newSize = size; @@ -3950,7 +3950,7 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const if (sectionStartposRecalc) recalcSectionStartPos(); int startidx = 0; - int endidx = sectionItems.count() - 1; + int endidx = sectionItems.size() - 1; while (startidx <= endidx) { int middle = (endidx + startidx) / 2; if (sectionItems.at(middle).calculated_startpos > position) { @@ -3973,7 +3973,7 @@ void QHeaderViewPrivate::setHeaderSectionResizeMode(int visual, QHeaderView::Res QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) const { - if (visual < 0 || visual >= sectionItems.count()) + if (visual < 0 || visual >= sectionItems.size()) return globalResizeMode; return static_cast<QHeaderView::ResizeMode>(sectionItems.at(visual).resizeMode); } @@ -3981,7 +3981,7 @@ QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) { globalResizeMode = mode; - for (int i = 0; i < sectionItems.count(); ++i) + for (int i = 0; i < sectionItems.size(); ++i) sectionItems[i].resizeMode = mode; } @@ -4000,7 +4000,7 @@ int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const if (!hiddenSectionSize.isEmpty()) { int adjustedVisualIndex = visualIndex; int currentVisualIndex = 0; - for (int i = 0; i < sectionItems.count(); ++i) { + for (int i = 0; i < sectionItems.size(); ++i) { if (isVisualIndexHidden(i)) ++adjustedVisualIndex; else @@ -4150,7 +4150,7 @@ bool QHeaderViewPrivate::read(QDataStream &in) // Now we have an itemvector where one items contains information about one section // For backward compatibility with Qt4 we do the following QList<SectionItem> newSectionItems; - for (int u = 0; u < sectionItemsIn.count(); ++u) { + for (int u = 0; u < sectionItemsIn.size(); ++u) { int count = sectionItemsIn.at(u).tmpDataStreamSectionCount; if (count > 1) sectionItemsIn[u].size /= count; @@ -4165,19 +4165,19 @@ bool QHeaderViewPrivate::read(QDataStream &in) return false; const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root)); - if (newSectionItems.count() < currentCount) { + if (newSectionItems.size() < currentCount) { // we have sections not in the saved state, give them default settings if (!visualIndicesIn.isEmpty() && !logicalIndicesIn.isEmpty()) { - for (int i = newSectionItems.count(); i < currentCount; ++i) { + for (int i = newSectionItems.size(); i < currentCount; ++i) { visualIndicesIn.append(i); logicalIndicesIn.append(i); } } - const int insertCount = currentCount - newSectionItems.count(); + const int insertCount = currentCount - newSectionItems.size(); const int insertLength = defaultSectionSizeIn * insertCount; lengthIn += insertLength; SectionItem section(defaultSectionSizeIn, globalResizeMode); - newSectionItems.insert(newSectionItems.count(), insertCount, section); // append + newSectionItems.insert(newSectionItems.size(), insertCount, section); // append } orientation = static_cast<Qt::Orientation>(orient); diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index fce525166d..c599aeff8d 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -120,12 +120,12 @@ public: inline void prepareSectionSelected() { if (!selectionModel || !selectionModel->hasSelection()) sectionSelected.clear(); - else if (sectionSelected.count() != sectionCount() * 2) + else if (sectionSelected.size() != sectionCount() * 2) sectionSelected.fill(false, sectionCount() * 2); else sectionSelected.fill(false); } - inline int sectionCount() const {return sectionItems.count();} + inline int sectionCount() const {return sectionItems.size();} inline bool reverse() const { return orientation == Qt::Horizontal && q_func()->isRightToLeft(); @@ -166,8 +166,8 @@ public: } inline void initializeIndexMapping() const { - if (visualIndices.count() != sectionCount() - || logicalIndices.count() != sectionCount()) { + if (visualIndices.size() != sectionCount() + || logicalIndices.size() != sectionCount()) { visualIndices.resize(sectionCount()); logicalIndices.resize(sectionCount()); for (int s = 0; s < sectionCount(); ++s) { @@ -178,7 +178,7 @@ public: } inline void clearCascadingSections() { - firstCascadingSection = sectionItems.count(); + firstCascadingSection = sectionItems.size(); lastCascadingSection = 0; cascadingSectionSize.clear(); } @@ -332,7 +332,7 @@ public: void setHiddenSectionsFromBitVector(const QBitArray §ionHidden) { SectionItem *sectionData = sectionItems.data(); - for (int i = 0; i < sectionHidden.count(); ++i) + for (int i = 0; i < sectionHidden.size(); ++i) sectionData[i].isHidden = sectionHidden.at(i); } diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index a2f3f0a2b6..d20289abff 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -891,7 +891,7 @@ void QListView::dropEvent(QDropEvent *event) if (!event->isAccepted() && d->dropOn(event, &row, &col, &topIndex)) { const QList<QModelIndex> selIndexes = selectedIndexes(); QList<QPersistentModelIndex> persIndexes; - persIndexes.reserve(selIndexes.count()); + persIndexes.reserve(selIndexes.size()); for (const auto &index : selIndexes) { persIndexes.append(index); @@ -908,7 +908,7 @@ void QListView::dropEvent(QDropEvent *event) int r = row == -1 ? model()->rowCount() : (dropRow.row() >= 0 ? dropRow.row() : row); bool dataMoved = false; - for (int i = 0; i < persIndexes.count(); ++i) { + for (int i = 0; i < persIndexes.size(); ++i) { const QPersistentModelIndex &pIndex = persIndexes.at(i); if (r != pIndex.row()) { // try to move (preserves selection) @@ -1097,7 +1097,7 @@ QModelIndex QListView::indexAt(const QPoint &p) const Q_D(const QListView); QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); const QList<QModelIndex> intersectVector = d->intersectingSet(rect); - QModelIndex index = intersectVector.count() > 0 + QModelIndex index = intersectVector.size() > 0 ? intersectVector.last() : QModelIndex(); if (index.isValid() && visualRect(index).contains(p)) return index; @@ -2159,7 +2159,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); const QList<QModelIndex> intersectVector = dd->intersectingSet(rect); - QModelIndex index = intersectVector.count() > 0 + QModelIndex index = intersectVector.size() > 0 ? intersectVector.last() : QModelIndex(); dd->hover = index; if (!dd->droppingOnItself(event, index) @@ -2238,7 +2238,7 @@ bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QM QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); const QList<QModelIndex> intersectVector = dd->intersectingSet(rect); - index = intersectVector.count() > 0 + index = intersectVector.size() > 0 ? intersectVector.last() : QModelIndex(); if (!index.isValid()) index = dd->root; @@ -2284,7 +2284,7 @@ void QListModeViewBase::updateVerticalScrollBar(const QSize &step) if (verticalScrollMode() == QAbstractItemView::ScrollPerItem && ((flow() == QListView::TopToBottom && !isWrapping()) || (flow() == QListView::LeftToRight && isWrapping()))) { - const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1; + const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).size() - 1; if (steps > 0) { const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping()); verticalScrollBar()->setSingleStep(1); @@ -2305,7 +2305,7 @@ void QListModeViewBase::updateHorizontalScrollBar(const QSize &step) if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem && ((flow() == QListView::TopToBottom && isWrapping()) || (flow() == QListView::LeftToRight && !isWrapping()))) { - int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1; + int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).size() - 1; if (steps > 0) { const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping()); horizontalScrollBar()->setSingleStep(1); @@ -2332,7 +2332,7 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi for (const auto &idx : qAsConst(dd->hiddenRows)) if (idx.row() <= scrollBarValue) ++numHidden; - value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.count() - 1); + value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.size() - 1); } if (above) hint = QListView::PositionAtTop; @@ -2352,7 +2352,7 @@ int QListModeViewBase::horizontalOffset() const if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) { if (isWrapping()) { if (flow() == QListView::TopToBottom && !segmentPositions.isEmpty()) { - const int max = segmentPositions.count() - 1; + const int max = segmentPositions.size() - 1; int currentValue = qBound(0, horizontalScrollBar()->value(), max); int position = segmentPositions.at(currentValue); int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max); @@ -2374,13 +2374,13 @@ int QListModeViewBase::verticalOffset() const if (isWrapping()) { if (flow() == QListView::LeftToRight && !segmentPositions.isEmpty()) { int value = verticalScrollBar()->value(); - if (value >= segmentPositions.count()) + if (value >= segmentPositions.size()) return 0; return segmentPositions.at(value) - spacing(); } } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) { int value = verticalScrollBar()->value(); - if (value > scrollValueMap.count()) + if (value > scrollValueMap.size()) return 0; return flowPositions.at(scrollValueMap.at(value)) - spacing(); } @@ -2398,7 +2398,7 @@ int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint if (scrollValueMap.isEmpty()) value = 0; else - value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); + value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.size() - 1); if (leftOf) hint = QListView::PositionAtTop; else if (rightOf) @@ -2420,7 +2420,7 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) if (isWrapping()) { if (segmentPositions.isEmpty()) return; - const int max = segmentPositions.count() - 1; + const int max = segmentPositions.size() - 1; if (horizontal && flow() == QListView::TopToBottom && dx != 0) { int currentValue = qBound(0, horizontalValue, max); int previousValue = qBound(0, currentValue + dx, max); @@ -2437,7 +2437,7 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) } else { if (flowPositions.isEmpty()) return; - const int max = scrollValueMap.count() - 1; + const int max = scrollValueMap.size() - 1; if (vertical && flow() == QListView::TopToBottom && dy != 0) { int currentValue = qBound(0, verticalValue, max); int previousValue = qBound(0, currentValue + dy, max); @@ -2465,11 +2465,11 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c { if (flowPositions.isEmpty() || segmentPositions.isEmpty() - || index.row() >= flowPositions.count() - 1) + || index.row() >= flowPositions.size() - 1) return QListViewItem(); const int segment = qBinarySearch<int>(segmentStartRows, index.row(), - 0, segmentStartRows.count() - 1); + 0, segmentStartRows.size() - 1); QStyleOptionViewItem options; @@ -2487,7 +2487,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c pos.setY(flowPositions.at(index.row())); pos.setX(segmentPositions.at(segment)); if (isWrapping()) { // make the items as wide as the segment - int right = (segment + 1 >= segmentPositions.count() + int right = (segment + 1 >= segmentPositions.size() ? contentsSize.width() : segmentPositions.at(segment + 1)); cellSize.setWidth(right - pos.x()); @@ -2611,7 +2611,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) deltaSegPosition = 0; } // save the flow position of this item - scrollValueMap.append(flowPositions.count()); + scrollValueMap.append(flowPositions.size()); flowPositions.append(flowPosition); // prepare for the next item deltaSegPosition = qMax(deltaSegHint, deltaSegPosition); @@ -2627,17 +2627,17 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) // set the contents size QRect rect = info.bounds; if (info.flow == QListView::LeftToRight) { - rect.setRight(segmentPositions.count() == 1 ? flowPosition : info.bounds.right()); + rect.setRight(segmentPositions.size() == 1 ? flowPosition : info.bounds.right()); rect.setBottom(segPosition + deltaSegPosition); } else { // TopToBottom rect.setRight(segPosition + deltaSegPosition); - rect.setBottom(segmentPositions.count() == 1 ? flowPosition : info.bounds.bottom()); + rect.setBottom(segmentPositions.size() == 1 ? flowPosition : info.bounds.bottom()); } contentsSize = QSize(rect.right(), rect.bottom()); // if it is the last batch, save the end of the segments if (info.last == info.max) { segmentExtents.append(flowPosition); - scrollValueMap.append(flowPositions.count()); + scrollValueMap.append(flowPositions.size()); flowPositions.append(flowPosition); segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX); } @@ -2670,10 +2670,10 @@ QList<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const flowStartPosition = area.top(); flowEndPosition = area.bottom(); } - if (segmentPositions.count() < 2 || flowPositions.isEmpty()) + if (segmentPositions.size() < 2 || flowPositions.isEmpty()) return ret; // the last segment position is actually the edge of the last segment - const int segLast = segmentPositions.count() - 2; + const int segLast = segmentPositions.size() - 2; int seg = qBinarySearch<int>(segmentPositions, segStartPosition, 0, segLast + 1); for (; seg <= segLast && segmentPositions.at(seg) <= segEndPosition; ++seg) { int first = segmentStartRows.at(seg); @@ -2740,15 +2740,15 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr positions.append(flowPositions.at(itemShown)); } if (positions.isEmpty() || bounds <= length) - return positions.count(); + return positions.size(); if (uniformItemSizes()) { - for (int i = 1; i < positions.count(); ++i) + for (int i = 1; i < positions.size(); ++i) if (positions.at(i) > 0) return length / positions.at(i); return 0; // all items had height 0 } int pageSteps = 0; - int steps = positions.count() - 1; + int steps = positions.size() - 1; int max = qMax(length, bounds); int min = qMin(length, bounds); int pos = min - (max - positions.constLast()); @@ -2810,7 +2810,7 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view // ### wrapped scrolling in the flow direction return flowPositions.at(index + hiddenRowsBefore); // ### always pixel based for now } else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction - int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1); + int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.size() - 1); int leftSegment = segment; const int rightSegment = leftSegment; const int bottomCoordinate = segmentPositions.at(segment); @@ -2853,7 +2853,7 @@ void QListModeViewBase::clear() void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index) { - if (index.row() >= items.count()) + if (index.row() >= items.size()) return; const QSize oldContents = contentsSize; qq->update(index); // update old position @@ -2866,7 +2866,7 @@ void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModel void QIconModeViewBase::appendHiddenRow(int row) { - if (row >= 0 && row < items.count()) //remove item + if (row >= 0 && row < items.size()) //remove item tree.removeLeaf(items.at(row).rect(), row); QCommonListViewBase::appendHiddenRow(row); } @@ -2874,7 +2874,7 @@ void QIconModeViewBase::appendHiddenRow(int row) void QIconModeViewBase::removeHiddenRow(int row) { QCommonListViewBase::removeHiddenRow(row); - if (row >= 0 && row < items.count()) //insert item + if (row >= 0 && row < items.size()) //insert item tree.insertLeaf(items.at(row).rect(), row); } @@ -2885,7 +2885,7 @@ bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions) // plus adding viewitems to the draggedItems list. // We need these items to draw the drag items QModelIndexList indexes = dd->selectionModel->selectedIndexes(); - if (indexes.count() > 0 ) { + if (indexes.size() > 0 ) { if (viewport()->acceptDrops()) { QModelIndexList::ConstIterator it = indexes.constBegin(); for (; it != indexes.constEnd(); ++it) @@ -2990,7 +2990,7 @@ bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e) if (movement() == QListView::Snap) { QRect rect(snapToGrid(e->position().toPoint() + offset()), gridSize()); const QList<QModelIndex> intersectVector = intersectingSet(rect); - index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex(); + index = intersectVector.size() > 0 ? intersectVector.last() : QModelIndex(); } else { index = qq->indexAt(e->position().toPoint()); } @@ -3029,7 +3029,7 @@ void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelInde if (column() >= topLeft.column() && column() <= bottomRight.column()) { QStyleOptionViewItem option; initViewItemOption(&option); - const int bottom = qMin(items.count(), bottomRight.row() + 1); + const int bottom = qMin(items.size(), bottomRight.row() + 1); const bool useItemSize = !dd->grid.isValid(); for (int row = topLeft.row(); row < bottom; ++row) { @@ -3046,11 +3046,11 @@ void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelInde bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max) { - if (info.last >= items.count()) { + if (info.last >= items.size()) { //first we create the items QStyleOptionViewItem option; initViewItemOption(&option); - for (int row = items.count(); row <= info.last; ++row) { + for (int row = items.size(); row <= info.last; ++row) { QSize size = itemSize(option, modelIndex(row)); QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos items.append(item); @@ -3062,7 +3062,7 @@ bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const { - if (index.isValid() && index.row() < items.count()) + if (index.isValid() && index.row() < items.size()) return items.at(index.row()); return QListViewItem(); } @@ -3140,8 +3140,8 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) segPosition = topLeft.x(); } - if (moved.count() != items.count()) - moved.resize(items.count()); + if (moved.size() != items.size()) + moved.resize(items.size()); QRect rect(QPoint(), topLeft); QListViewItem *item = nullptr; @@ -3269,15 +3269,15 @@ int QIconModeViewBase::itemIndex(const QListViewItem &item) const if (!item.isValid()) return -1; int i = item.indexHint; - if (i < items.count()) { + if (i < items.size()) { if (items.at(i) == item) return i; } else { - i = items.count() - 1; + i = items.size() - 1; } int j = i; - int c = items.count(); + int c = items.size(); bool a = true; bool b = true; @@ -3305,9 +3305,9 @@ void QIconModeViewBase::addLeaf(QList<int> &leaf, const QRect &area, uint visite { QListViewItem *vi; QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr); - for (int i = 0; i < leaf.count(); ++i) { + for (int i = 0; i < leaf.size(); ++i) { int idx = leaf.at(i); - if (idx < 0 || idx >= _this->items.count()) + if (idx < 0 || idx >= _this->items.size()) continue; vi = &_this->items[idx]; Q_ASSERT(vi); @@ -3335,8 +3335,8 @@ void QIconModeViewBase::moveItem(int index, const QPoint &dest) contentsSize = (QRect(QPoint(0, 0), contentsSize)|QRect(dest, rect.size())).size(); // mark the item as moved - if (moved.count() != items.count()) - moved.resize(items.count()); + if (moved.size() != items.size()) + moved.resize(items.size()); moved.setBit(index, true); } @@ -3388,7 +3388,7 @@ void QIconModeViewBase::clear() void QIconModeViewBase::updateContentsSize() { QRect bounding; - for (int i = 0; i < items.count(); ++i) + for (int i = 0; i < items.size(); ++i) bounding |= items.at(i).rect(); contentsSize = bounding.size(); } diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 2095d596ab..de928bbb28 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -460,7 +460,7 @@ inline QAbstractItemDelegate *QCommonListViewBase::delegate(const QModelIndex &i { return qq->itemDelegateForIndex(idx); } inline bool QCommonListViewBase::isHidden(int row) const { return dd->isHidden(row); } -inline int QCommonListViewBase::hiddenCount() const { return dd->hiddenRows.count(); } +inline int QCommonListViewBase::hiddenCount() const { return dd->hiddenRows.size(); } inline bool QCommonListViewBase::isRightToLeft() const { return qq->isRightToLeft(); } diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 5080ab8fc5..cc0ccf84da 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -36,7 +36,7 @@ QListModel::~QListModel() void QListModel::clear() { beginResetModel(); - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { if (items.at(i)) { items.at(i)->d->theid = -1; items.at(i)->view = nullptr; @@ -80,8 +80,8 @@ void QListModel::insert(int row, QListWidgetItem *item) } else { if (row < 0) row = 0; - else if (row > items.count()) - row = items.count(); + else if (row > items.size()) + row = items.size(); } beginInsertRows(QModelIndex(), row, row); items.insert(row, item); @@ -91,7 +91,7 @@ void QListModel::insert(int row, QListWidgetItem *item) void QListModel::insert(int row, const QStringList &labels) { - const int count = labels.count(); + const int count = labels.size(); if (count <= 0) return; QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); @@ -104,8 +104,8 @@ void QListModel::insert(int row, const QStringList &labels) } else { if (row < 0) row = 0; - else if (row > items.count()) - row = items.count(); + else if (row > items.size()) + row = items.size(); beginInsertRows(QModelIndex(), row, row + count - 1); for (int i = 0; i < count; ++i) { QListWidgetItem *item = new QListWidgetItem(labels.at(i)); @@ -119,7 +119,7 @@ void QListModel::insert(int row, const QStringList &labels) QListWidgetItem *QListModel::take(int row) { - if (row < 0 || row >= items.count()) + if (row < 0 || row >= items.size()) return nullptr; beginRemoveRows(QModelIndex(), row, row); @@ -133,8 +133,8 @@ QListWidgetItem *QListModel::take(int row) void QListModel::move(int srcRow, int dstRow) { if (srcRow == dstRow - || srcRow < 0 || srcRow >= items.count() - || dstRow < 0 || dstRow > items.count()) + || srcRow < 0 || srcRow >= items.size() + || dstRow < 0 || dstRow > items.size()) return; if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) @@ -147,7 +147,7 @@ void QListModel::move(int srcRow, int dstRow) int QListModel::rowCount(const QModelIndex &parent) const { - return parent.isValid() ? 0 : items.count(); + return parent.isValid() ? 0 : items.size(); } QModelIndex QListModel::index(const QListWidgetItem *item_) const @@ -158,7 +158,7 @@ QModelIndex QListModel::index(const QListWidgetItem *item_) const return QModelIndex(); int row; const int theid = item->d->theid; - if (theid >= 0 && theid < items.count() && items.at(theid) == item) { + if (theid >= 0 && theid < items.size() && items.at(theid) == item) { row = theid; } else { // we need to search for the item row = items.lastIndexOf(item); // lastIndexOf is an optimization in favor of indexOf @@ -178,14 +178,14 @@ QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) co QVariant QListModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() >= items.count()) + if (!index.isValid() || index.row() >= items.size()) return QVariant(); return items.at(index.row())->data(role); } bool QListModel::setData(const QModelIndex &index, const QVariant &value, int role) { - if (!index.isValid() || index.row() >= items.count()) + if (!index.isValid() || index.row() >= items.size()) return false; items.at(index.row())->setData(role, value); return true; @@ -208,10 +208,10 @@ bool QListModel::clearItemData(const QModelIndex &index) QMap<int, QVariant> QListModel::itemData(const QModelIndex &index) const { QMap<int, QVariant> roles; - if (!index.isValid() || index.row() >= items.count()) + if (!index.isValid() || index.row() >= items.size()) return roles; QListWidgetItem *itm = items.at(index.row()); - for (int i = 0; i < itm->d->values.count(); ++i) { + for (int i = 0; i < itm->d->values.size(); ++i) { roles.insert(itm->d->values.at(i).role, itm->d->values.at(i).value); } @@ -288,7 +288,7 @@ bool QListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int co Qt::ItemFlags QListModel::flags(const QModelIndex &index) const { - if (!index.isValid() || index.row() >= items.count() || index.model() != this) + if (!index.isValid() || index.row() >= items.size() || index.model() != this) return Qt::ItemIsDropEnabled; // we allow drops outside the items return items.at(index.row())->flags(); } @@ -300,8 +300,8 @@ void QListModel::sort(int column, Qt::SortOrder order) emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint); - QList<QPair<QListWidgetItem *, int>> sorting(items.count()); - for (int i = 0; i < items.count(); ++i) { + QList<QPair<QListWidgetItem *, int>> sorting(items.size()); + for (int i = 0; i < items.size(); ++i) { QListWidgetItem *item = items.at(i); sorting[i].first = item; sorting[i].second = i; @@ -311,7 +311,7 @@ void QListModel::sort(int column, Qt::SortOrder order) std::sort(sorting.begin(), sorting.end(), compare); QModelIndexList fromIndexes; QModelIndexList toIndexes; - const int sortingCount = sorting.count(); + const int sortingCount = sorting.size(); fromIndexes.reserve(sortingCount); toIndexes.reserve(sortingCount); for (int r = 0; r < sortingCount; ++r) { @@ -376,7 +376,7 @@ void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int en else if (oldRow > otherRow && newRow <= otherRow) ++sorting[j].second; } - for (int k = 0; k < newPersistentIndexes.count(); ++k) { + for (int k = 0; k < newPersistentIndexes.size(); ++k) { QModelIndex pi = newPersistentIndexes.at(k); int oldPersistentRow = pi.row(); int newPersistentRow = oldPersistentRow; @@ -444,7 +444,7 @@ QMimeData *QListModel::internalMimeData() const QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const { QList<QListWidgetItem*> itemlist; - const int indexesCount = indexes.count(); + const int indexesCount = indexes.size(); itemlist.reserve(indexesCount); for (int i = 0; i < indexesCount; ++i) itemlist << at(indexes.at(i).row()); @@ -465,7 +465,7 @@ bool QListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, if (index.isValid()) row = index.row(); else if (row == -1) - row = items.count(); + row = items.size(); return view->dropMimeData(row, data, action); } @@ -702,7 +702,7 @@ void QListWidgetItem::setData(int role, const QVariant &value) { bool found = false; role = (role == Qt::EditRole ? Qt::DisplayRole : role); - for (int i = 0; i < d->values.count(); ++i) { + for (int i = 0; i < d->values.size(); ++i) { if (d->values.at(i).role == role) { if (d->values.at(i).value == value) return; @@ -730,7 +730,7 @@ void QListWidgetItem::setData(int role, const QVariant &value) QVariant QListWidgetItem::data(int role) const { role = (role == Qt::EditRole ? Qt::DisplayRole : role); - for (int i = 0; i < d->values.count(); ++i) + for (int i = 0; i < d->values.size(); ++i) if (d->values.at(i).role == role) return d->values.at(i).value; return QVariant(); @@ -1760,7 +1760,7 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const Q_D(const QListWidget); QModelIndexList indexes = selectionModel()->selectedIndexes(); QList<QListWidgetItem*> items; - const int numIndexes = indexes.count(); + const int numIndexes = indexes.size(); items.reserve(numIndexes); for (int i = 0; i < numIndexes; ++i) items.append(d->listModel()->at(indexes.at(i).row())); @@ -1837,7 +1837,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem *> &items) const // if non empty, it's called from the model's own mimeData if (cachedIndexes.isEmpty()) { - cachedIndexes.reserve(items.count()); + cachedIndexes.reserve(items.size()); for (QListWidgetItem *item : items) cachedIndexes << indexFromItem(item); diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 2f46842712..b2048db845 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -2197,7 +2197,7 @@ QModelIndexList QTableView::selectedIndexes() const QModelIndexList modelSelected; if (d->selectionModel) modelSelected = d->selectionModel->selectedIndexes(); - for (int i = 0; i < modelSelected.count(); ++i) { + for (int i = 0; i < modelSelected.size(); ++i) { QModelIndex index = modelSelected.at(i); if (!isIndexHidden(index) && index.parent() == d->root) viewSelected.append(index); diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index ae523b2dda..67886be94f 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -27,12 +27,12 @@ QTableModel::~QTableModel() bool QTableModel::insertRows(int row, int count, const QModelIndex &) { - if (count < 1 || row < 0 || row > verticalHeaderItems.count()) + if (count < 1 || row < 0 || row > verticalHeaderItems.size()) return false; beginInsertRows(QModelIndex(), row, row + count - 1); - int rc = verticalHeaderItems.count(); - int cc = horizontalHeaderItems.count(); + int rc = verticalHeaderItems.size(); + int cc = horizontalHeaderItems.size(); verticalHeaderItems.insert(row, count, 0); if (rc == 0) tableItems.resize(cc * count); @@ -44,12 +44,12 @@ bool QTableModel::insertRows(int row, int count, const QModelIndex &) bool QTableModel::insertColumns(int column, int count, const QModelIndex &) { - if (count < 1 || column < 0 || column > horizontalHeaderItems.count()) + if (count < 1 || column < 0 || column > horizontalHeaderItems.size()) return false; beginInsertColumns(QModelIndex(), column, column + count - 1); - int rc = verticalHeaderItems.count(); - int cc = horizontalHeaderItems.count(); + int rc = verticalHeaderItems.size(); + int cc = horizontalHeaderItems.size(); horizontalHeaderItems.insert(column, count, 0); if (cc == 0) tableItems.resize(rc * count); @@ -62,7 +62,7 @@ bool QTableModel::insertColumns(int column, int count, const QModelIndex &) bool QTableModel::removeRows(int row, int count, const QModelIndex &) { - if (count < 1 || row < 0 || row + count > verticalHeaderItems.count()) + if (count < 1 || row < 0 || row + count > verticalHeaderItems.size()) return false; beginRemoveRows(QModelIndex(), row, row + count - 1); @@ -89,7 +89,7 @@ bool QTableModel::removeRows(int row, int count, const QModelIndex &) bool QTableModel::removeColumns(int column, int count, const QModelIndex &) { - if (count < 1 || column < 0 || column + count > horizontalHeaderItems.count()) + if (count < 1 || column < 0 || column + count > horizontalHeaderItems.size()) return false; beginRemoveColumns(QModelIndex(), column, column + count - 1); @@ -118,7 +118,7 @@ bool QTableModel::removeColumns(int column, int count, const QModelIndex &) void QTableModel::setItem(int row, int column, QTableWidgetItem *item) { int i = tableIndex(row, column); - if (i < 0 || i >= tableItems.count()) + if (i < 0 || i >= tableItems.size()) return; QTableWidgetItem *oldItem = tableItems.at(i); if (item == oldItem) @@ -141,12 +141,12 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item) // sorted insertion Qt::SortOrder order = view->horizontalHeader()->sortIndicatorOrder(); QList<QTableWidgetItem *> colItems = columnItems(column); - if (row < colItems.count()) + if (row < colItems.size()) colItems.remove(row); int sortedRow; if (item == nullptr) { // move to after all non-0 (sortable) items - sortedRow = colItems.count(); + sortedRow = colItems.size(); } else { QList<QTableWidgetItem *>::iterator it; it = sortedInsertionIterator(colItems.begin(), colItems.end(), order, item); @@ -234,7 +234,7 @@ void QTableModel::removeItem(QTableWidgetItem *item) void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item) { - if (section < 0 || section >= horizontalHeaderItems.count()) + if (section < 0 || section >= horizontalHeaderItems.size()) return; QTableWidgetItem *oldItem = horizontalHeaderItems.at(section); if (item == oldItem) @@ -256,7 +256,7 @@ void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item) void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) { - if (section < 0 || section >= verticalHeaderItems.count()) + if (section < 0 || section >= verticalHeaderItems.size()) return; QTableWidgetItem *oldItem = verticalHeaderItems.at(section); if (item == oldItem) @@ -278,7 +278,7 @@ void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) { - if (section < 0 || section >= horizontalHeaderItems.count()) + if (section < 0 || section >= horizontalHeaderItems.size()) return nullptr; QTableWidgetItem *itm = horizontalHeaderItems.at(section); if (itm) { @@ -291,7 +291,7 @@ QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) QTableWidgetItem *QTableModel::takeVerticalHeaderItem(int section) { - if (section < 0 || section >= verticalHeaderItems.count()) + if (section < 0 || section >= verticalHeaderItems.size()) return nullptr; QTableWidgetItem *itm = verticalHeaderItems.at(section); if (itm) { @@ -318,7 +318,7 @@ QModelIndex QTableModel::index(const QTableWidgetItem *item) const return QModelIndex(); int i = -1; const int id = item->d->id; - if (id >= 0 && id < tableItems.count() && tableItems.at(id) == item) { + if (id >= 0 && id < tableItems.size() && tableItems.at(id) == item) { i = id; } else { // we need to search for the item i = tableItems.indexOf(const_cast<QTableWidgetItem*>(item)); @@ -332,7 +332,7 @@ QModelIndex QTableModel::index(const QTableWidgetItem *item) const void QTableModel::setRowCount(int rows) { - int rc = verticalHeaderItems.count(); + int rc = verticalHeaderItems.size(); if (rows < 0 || rc == rows) return; if (rc < rows) @@ -343,7 +343,7 @@ void QTableModel::setRowCount(int rows) void QTableModel::setColumnCount(int columns) { - int cc = horizontalHeaderItems.count(); + int cc = horizontalHeaderItems.size(); if (columns < 0 || cc == columns) return; if (cc < columns) @@ -354,12 +354,12 @@ void QTableModel::setColumnCount(int columns) int QTableModel::rowCount(const QModelIndex &parent) const { - return parent.isValid() ? 0 : verticalHeaderItems.count(); + return parent.isValid() ? 0 : verticalHeaderItems.size(); } int QTableModel::columnCount(const QModelIndex &parent) const { - return parent.isValid() ? 0 : horizontalHeaderItems.count(); + return parent.isValid() ? 0 : horizontalHeaderItems.size(); } QVariant QTableModel::data(const QModelIndex &index, int role) const @@ -400,7 +400,7 @@ QMap<int, QVariant> QTableModel::itemData(const QModelIndex &index) const QMap<int, QVariant> roles; QTableWidgetItem *itm = item(index); if (itm) { - for (int i = 0; i < itm->values.count(); ++i) { + for (int i = 0; i < itm->values.size(); ++i) { roles.insert(itm->values.at(i).role, itm->values.at(i).value); } @@ -492,7 +492,7 @@ void QTableModel::sort(int column, Qt::SortOrder order) const auto compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); std::stable_sort(sortable.begin(), sortable.end(), compare); - QList<QTableWidgetItem *> sorted_table(tableItems.count()); + QList<QTableWidgetItem *> sorted_table(tableItems.size()); QModelIndexList from; QModelIndexList to; const int numRows = rowCount(); @@ -500,9 +500,9 @@ void QTableModel::sort(int column, Qt::SortOrder order) from.reserve(numRows * numColumns); to.reserve(numRows * numColumns); for (int i = 0; i < numRows; ++i) { - int r = (i < sortable.count() + int r = (i < sortable.size() ? sortable.at(i).second - : unsortable.at(i - sortable.count())); + : unsortable.at(i - sortable.size())); for (int c = 0; c < numColumns; ++c) { sorted_table[tableIndex(i, c)] = item(r, c); from.append(createIndex(r, c)); @@ -550,7 +550,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order, QList<QTableWidgetItem *>::iterator vit = colItems.begin(); qsizetype distanceFromBegin = 0; bool changed = false; - for (int i = 0; i < sorting.count(); ++i) { + for (int i = 0; i < sorting.size(); ++i) { distanceFromBegin = std::distance(colItems.begin(), vit); int oldRow = sorting.at(i).second; QTableWidgetItem *item = colItems.at(oldRow); @@ -583,7 +583,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order, // update persistent indexes updateRowIndexes(newPersistentIndexes, oldRow, newRow); // the index of the remaining rows may have changed - for (int j = i + 1; j < sorting.count(); ++j) { + for (int j = i + 1; j < sorting.size(); ++j) { int otherRow = sorting.at(j).second; if (oldRow < otherRow && newRow >= otherRow) --sorting[j].second; @@ -684,9 +684,9 @@ QVariant QTableModel::headerData(int section, Qt::Orientation orientation, int r return QVariant(); QTableWidgetItem *itm = nullptr; - if (orientation == Qt::Horizontal && section < horizontalHeaderItems.count()) + if (orientation == Qt::Horizontal && section < horizontalHeaderItems.size()) itm = horizontalHeaderItems.at(section); - else if (orientation == Qt::Vertical && section < verticalHeaderItems.count()) + else if (orientation == Qt::Vertical && section < verticalHeaderItems.size()) itm = verticalHeaderItems.at(section); else return QVariant(); // section is out of bounds @@ -721,20 +721,20 @@ bool QTableModel::setHeaderData(int section, Qt::Orientation orientation, bool QTableModel::isValid(const QModelIndex &index) const { return (index.isValid() - && index.row() < verticalHeaderItems.count() - && index.column() < horizontalHeaderItems.count()); + && index.row() < verticalHeaderItems.size() + && index.column() < horizontalHeaderItems.size()); } void QTableModel::clear() { - for (int j = 0; j < verticalHeaderItems.count(); ++j) { + for (int j = 0; j < verticalHeaderItems.size(); ++j) { if (verticalHeaderItems.at(j)) { verticalHeaderItems.at(j)->view = nullptr; delete verticalHeaderItems.at(j); verticalHeaderItems[j] = 0; } } - for (int k = 0; k < horizontalHeaderItems.count(); ++k) { + for (int k = 0; k < horizontalHeaderItems.size(); ++k) { if (horizontalHeaderItems.at(k)) { horizontalHeaderItems.at(k)->view = nullptr; delete horizontalHeaderItems.at(k); @@ -747,7 +747,7 @@ void QTableModel::clear() void QTableModel::clearContents() { beginResetModel(); - for (int i = 0; i < tableItems.count(); ++i) { + for (int i = 0; i < tableItems.size(); ++i) { if (tableItems.at(i)) { tableItems.at(i)->view = nullptr; delete tableItems.at(i); @@ -809,7 +809,7 @@ QMimeData *QTableModel::internalMimeData() const QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const { QList<QTableWidgetItem*> items; - const int indexesCount = indexes.count(); + const int indexesCount = indexes.size(); items.reserve(indexesCount); for (int i = 0; i < indexesCount; ++i) items << item(indexes.at(i)); @@ -1380,7 +1380,7 @@ void QTableWidgetItem::setData(int role, const QVariant &value) { bool found = false; role = (role == Qt::EditRole ? Qt::DisplayRole : role); - for (int i = 0; i < values.count(); ++i) { + for (int i = 0; i < values.size(); ++i) { if (values.at(i).role == role) { if (values[i].value == value) return; @@ -2087,7 +2087,7 @@ void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) Q_D(QTableWidget); QTableModel *model = d->tableModel(); QTableWidgetItem *item = nullptr; - for (int i = 0; i < model->rowCount() && i < labels.count(); ++i) { + for (int i = 0; i < model->rowCount() && i < labels.size(); ++i) { item = model->verticalHeaderItem(i); if (!item) { item = model->createItem(); @@ -2105,7 +2105,7 @@ void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels) Q_D(QTableWidget); QTableModel *model = d->tableModel(); QTableWidgetItem *item = nullptr; - for (int i = 0; i < model->columnCount() && i < labels.count(); ++i) { + for (int i = 0; i < model->columnCount() && i < labels.size(); ++i) { item = model->horizontalHeaderItem(i); if (!item) { item = model->createItem(); @@ -2344,7 +2344,7 @@ QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const { const QList<QItemSelectionRange> ranges = selectionModel()->selection(); QList<QTableWidgetSelectionRange> result; - const int rangesCount = ranges.count(); + const int rangesCount = ranges.size(); result.reserve(rangesCount); for (int i = 0; i < rangesCount; ++i) result.append({ranges.at(i).top(), @@ -2582,7 +2582,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem *> &items) const // if non empty, it's called from the model's own mimeData if (cachedIndexes.isEmpty()) { - cachedIndexes.reserve(items.count()); + cachedIndexes.reserve(items.size()); for (QTableWidgetItem *item : items) cachedIndexes << indexFromItem(item); @@ -2697,7 +2697,7 @@ void QTableWidget::dropEvent(QDropEvent *event) { } QList<QTableWidgetItem *> taken; - const int indexesCount = indexes.count(); + const int indexesCount = indexes.size(); taken.reserve(indexesCount); for (const auto &index : indexes) taken.append(takeItem(index.row(), index.column())); diff --git a/src/widgets/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h index 2c4193c0de..1d893224c0 100644 --- a/src/widgets/itemviews/qtablewidget_p.h +++ b/src/widgets/itemviews/qtablewidget_p.h @@ -118,7 +118,7 @@ public: bool isValid(const QModelIndex &index) const; inline long tableIndex(int row, int column) const - { return (row * horizontalHeaderItems.count()) + column; } + { return (row * horizontalHeaderItems.size()) + column; } void clear(); void clearContents(); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index e45807c39f..065c42d6b7 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1002,9 +1002,9 @@ void QTreeView::keyboardSearch(const QString &search) // special case for searches with same key like 'aaaaa' bool sameKey = false; - if (d->keyboardInput.length() > 1) { - int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); - sameKey = (c == d->keyboardInput.length()); + if (d->keyboardInput.size() > 1) { + int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.size() - 1)); + sameKey = (c == d->keyboardInput.size()); if (sameKey) skipRow = true; } @@ -1029,7 +1029,7 @@ void QTreeView::keyboardSearch(const QString &search) int bestAbove = -1; int bestBelow = -1; QString searchString = sameKey ? QString(d->keyboardInput.at(0)) : d->keyboardInput; - for (int i = 0; i < d->viewItems.count(); ++i) { + for (int i = 0; i < d->viewItems.size(); ++i) { if ((int)d->viewItems.at(i).level > previousLevel) { QModelIndex searchFrom = d->viewItems.at(i).index; if (start.column() > 0) @@ -1037,7 +1037,7 @@ void QTreeView::keyboardSearch(const QString &search) if (searchFrom.parent() == start.parent()) searchFrom = start; QModelIndexList match = d->model->match(searchFrom, Qt::DisplayRole, searchString); - if (match.count()) { + if (match.size()) { int hitIndex = d->viewIndex(match.at(0)); if (hitIndex >= 0 && hitIndex < startIndex) bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove); @@ -1458,7 +1458,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const const QStyle::State state = option.state; d->current = 0; - if (viewItems.count() == 0 || d->header->count() == 0 || !d->itemDelegate) { + if (viewItems.size() == 0 || d->header->count() == 0 || !d->itemDelegate) { d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1); return; } @@ -1487,7 +1487,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const int y = firstVisibleItemOffset; // we may only see part of the first item // start at the top of the viewport and iterate down to the update area - for (; i < viewItems.count(); ++i) { + for (; i < viewItems.size(); ++i) { const int itemHeight = d->itemHeight(i); if (y + itemHeight > area.top()) break; @@ -1495,7 +1495,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const } // paint the visible rows - for (; i < viewItems.count() && y <= area.bottom(); ++i) { + for (; i < viewItems.size() && y <= area.bottom(); ++i) { const int itemHeight = d->itemHeight(i); option.rect.setRect(0, y, viewportWidth, itemHeight); option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None) @@ -1556,11 +1556,11 @@ void QTreeViewPrivate::calcLogicalIndices( } } - itemPositions->resize(logicalIndices->count()); - for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) { + itemPositions->resize(logicalIndices->size()); + for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->size(); ++currentLogicalSection) { const int headerSection = logicalIndices->at(currentLogicalSection); // determine the viewItemPosition depending on the position of column 0 - int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count() + int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->size() ? logicalIndexAfterRight : logicalIndices->at(currentLogicalSection + 1); int prevLogicalSection = currentLogicalSection - 1 < 0 @@ -1679,7 +1679,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, viewItemPosList; // vector of left/middle/end for each logicalIndex d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); - for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) { + for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.size(); ++currentLogicalSection) { int headerSection = logicalIndices.at(currentLogicalSection); position = columnViewportPosition(headerSection) + offset.x(); width = header->sectionSize(headerSection); @@ -1973,13 +1973,13 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) if (d->itemsExpandable && d->expandsOnDoubleClick && d->hasVisibleChildren(persistent)) { - if (!((i < d->viewItems.count()) && (d->viewItems.at(i).index == firstColumnIndex))) { + if (!((i < d->viewItems.size()) && (d->viewItems.at(i).index == firstColumnIndex))) { // find the new index of the item - for (i = 0; i < d->viewItems.count(); ++i) { + for (i = 0; i < d->viewItems.size(); ++i) { if (d->viewItems.at(i).index == firstColumnIndex) break; } - if (i == d->viewItems.count()) + if (i == d->viewItems.size()) return; } if (d->viewItems.at(i).expanded) @@ -2077,7 +2077,7 @@ QModelIndex QTreeView::indexBelow(const QModelIndex &index) const return QModelIndex(); d->executePostedLayout(); int i = d->viewIndex(index); - if (++i >= d->viewItems.count()) + if (++i >= d->viewItems.size()) return QModelIndex(); const QModelIndex firstColumnIndex = d->viewItems.at(i).index; return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); @@ -2161,7 +2161,7 @@ int QTreeView::verticalOffset() const // ### find a faster way to do this d->executePostedLayout(); int offset = 0; - const int cnt = qMin(d->viewItems.count(), verticalScrollBar()->value()); + const int cnt = qMin(d->viewItems.size(), verticalScrollBar()->value()); for (int i = 0; i < cnt; ++i) offset += d->itemHeight(i); return offset; @@ -2187,7 +2187,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie int c = 0; while (c < d->header->count() && d->header->isSectionHidden(d->header->logicalIndex(c))) ++c; - if (i < d->viewItems.count() && c < d->header->count()) { + if (i < d->viewItems.size() && c < d->header->count()) { return d->modelIndex(i, d->header->logicalIndex(c)); } return QModelIndex(); @@ -2219,7 +2219,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie return d->modelIndex(d->above(vi), current.column()); case MoveLeft: { QScrollBar *sb = horizontalScrollBar(); - if (vi < d->viewItems.count() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) { + if (vi < d->viewItems.size() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) { d->collapse(vi, true); d->moveCursorUpdatedView = true; } else { @@ -2254,7 +2254,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie break; } case MoveRight: - if (vi < d->viewItems.count() && !d->viewItems.at(vi).expanded && d->itemsExpandable + if (vi < d->viewItems.size() && !d->viewItems.at(vi).expanded && d->itemsExpandable && d->hasVisibleChildren(d->viewItems.at(vi).index)) { d->expand(vi, true); d->moveCursorUpdatedView = true; @@ -2409,7 +2409,7 @@ QModelIndexList QTreeView::selectedIndexes() const QModelIndexList modelSelected; if (selectionModel()) modelSelected = selectionModel()->selectedIndexes(); - for (int i = 0; i < modelSelected.count(); ++i) { + for (int i = 0; i < modelSelected.size(); ++i) { // check that neither the parents nor the index is hidden before we add QModelIndex index = modelSelected.at(i); while (index.isValid() && !isIndexHidden(index)) @@ -2446,7 +2446,7 @@ void QTreeView::scrollContentsBy(int dx, int dy) // guestimate the number of items in the viewport int viewCount = d->viewport->height() / itemHeight; - int maxDeltaY = qMin(d->viewItems.count(), viewCount); + int maxDeltaY = qMin(d->viewItems.size(), viewCount); // no need to do a lot of work if we are going to redraw the whole thing anyway if (qAbs(dy) > qAbs(maxDeltaY) && d->editorIndexHash.isEmpty()) { verticalScrollBar()->update(); @@ -2462,12 +2462,12 @@ void QTreeView::scrollContentsBy(int dx, int dy) dy = 0; if (previousViewIndex < currentViewIndex) { // scrolling down for (int i = previousViewIndex; i < currentViewIndex; ++i) { - if (i < d->viewItems.count()) + if (i < d->viewItems.size()) dy -= d->itemHeight(i); } } else if (previousViewIndex > currentViewIndex) { // scrolling up for (int i = previousViewIndex - 1; i >= currentViewIndex; --i) { - if (i < d->viewItems.count()) + if (i < d->viewItems.size()) dy += d->itemHeight(i); } } @@ -2770,7 +2770,7 @@ void QTreeView::expandToDepth(int depth) d->expandedIndexes.clear(); d->interruptDelayedItemsLayout(); d->layout(-1); - for (int i = 0; i < d->viewItems.count(); ++i) { + for (int i = 0; i < d->viewItems.size(); ++i) { if (d->viewItems.at(i).level <= (uint)depth) { d->viewItems[i].expanded = true; d->layout(i); @@ -3104,7 +3104,7 @@ void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem & { viewItems.insert(pos, count, viewItem); QTreeViewItem *items = viewItems.data(); - for (int i = pos + count; i < viewItems.count(); i++) + for (int i = pos + count; i < viewItems.size(); i++) if (items[i].parentItem >= pos) items[i].parentItem += count; } @@ -3113,7 +3113,7 @@ void QTreeViewPrivate::removeViewItems(int pos, int count) { viewItems.remove(pos, count); QTreeViewItem *items = viewItems.data(); - for (int i = pos; i < viewItems.count(); i++) + for (int i = pos; i < viewItems.size(); i++) if (items[i].parentItem >= pos) items[i].parentItem -= count; } @@ -3357,7 +3357,7 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit if (!afterIsUninitialized) insertViewItems(i + 1, count, QTreeViewItem()); // expand else if (count > 0) - viewItems.resize(viewItems.count() + count); + viewItems.resize(viewItems.size() + count); } else { expanding = false; } @@ -3427,7 +3427,7 @@ int QTreeViewPrivate::pageUp(int i) const index = 0; while (isItemHiddenOrDisabled(index)) index++; - return index >= viewItems.count() ? 0 : index; + return index >= viewItems.size() ? 0 : index; } int QTreeViewPrivate::pageDown(int i) const @@ -3435,11 +3435,11 @@ int QTreeViewPrivate::pageDown(int i) const int index = itemAtCoordinate(coordinateForItem(i) + viewport->height()); while (isItemHiddenOrDisabled(index)) index++; - if (index == -1 || index >= viewItems.count()) - index = viewItems.count() - 1; + if (index == -1 || index >= viewItems.size()) + index = viewItems.size() - 1; while (isItemHiddenOrDisabled(index)) index--; - return index == -1 ? viewItems.count() - 1 : index; + return index == -1 ? viewItems.size() - 1 : index; } int QTreeViewPrivate::itemForKeyHome() const @@ -3447,20 +3447,20 @@ int QTreeViewPrivate::itemForKeyHome() const int index = 0; while (isItemHiddenOrDisabled(index)) index++; - return index >= viewItems.count() ? 0 : index; + return index >= viewItems.size() ? 0 : index; } int QTreeViewPrivate::itemForKeyEnd() const { - int index = viewItems.count() - 1; + int index = viewItems.size() - 1; while (isItemHiddenOrDisabled(index)) index--; - return index == -1 ? viewItems.count() - 1 : index; + return index == -1 ? viewItems.size() - 1 : index; } int QTreeViewPrivate::indentationForItem(int item) const { - if (item < 0 || item >= viewItems.count()) + if (item < 0 || item >= viewItems.size()) return 0; int level = viewItems.at(item).level; if (rootDecoration) @@ -3470,7 +3470,7 @@ int QTreeViewPrivate::indentationForItem(int item) const int QTreeViewPrivate::itemHeight(int item) const { - Q_ASSERT(item < viewItems.count()); + Q_ASSERT(item < viewItems.size()); if (uniformRowHeights) return defaultItemHeight; if (viewItems.isEmpty()) @@ -3498,7 +3498,7 @@ int QTreeViewPrivate::coordinateForItem(int item) const return (item * defaultItemHeight) - vbar->value(); // ### optimize (maybe do like QHeaderView by letting items have startposition) int y = 0; - for (int i = 0; i < viewItems.count(); ++i) { + for (int i = 0; i < viewItems.size(); ++i) { if (i == item) return y - vbar->value(); y += itemHeight(i); @@ -3512,7 +3512,7 @@ int QTreeViewPrivate::coordinateForItem(int item) const // ### slow if the item is not visible int viewItemCoordinate = 0; int viewItemIndex = topViewItemIndex; - while (viewItemIndex < viewItems.count()) { + while (viewItemIndex < viewItems.size()) { if (viewItemIndex == item) return viewItemCoordinate; viewItemCoordinate += itemHeight(viewItemIndex); @@ -3544,7 +3544,7 @@ int QTreeViewPrivate::coordinateForItem(int item) const */ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const { - const int itemCount = viewItems.count(); + const int itemCount = viewItems.size(); if (itemCount == 0) return -1; if (uniformRowHeights && defaultItemHeight <= 0) @@ -3557,7 +3557,7 @@ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const // ### optimize int viewItemCoordinate = 0; const int contentsCoordinate = coordinate + vbar->value(); - for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) { + for (int viewItemIndex = 0; viewItemIndex < viewItems.size(); ++viewItemIndex) { viewItemCoordinate += itemHeight(viewItemIndex); if (viewItemCoordinate > contentsCoordinate) return (viewItemIndex >= itemCount ? -1 : viewItemIndex); @@ -3573,7 +3573,7 @@ int QTreeViewPrivate::itemAtCoordinate(int coordinate) const if (coordinate >= 0) { // the coordinate is in or below the viewport int viewItemCoordinate = 0; - for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.count(); ++viewItemIndex) { + for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.size(); ++viewItemIndex) { viewItemCoordinate += itemHeight(viewItemIndex); if (viewItemCoordinate > coordinate) return (viewItemIndex >= itemCount ? -1 : viewItemIndex); @@ -3596,7 +3596,7 @@ int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const if (!_index.isValid() || viewItems.isEmpty()) return -1; - const int totalCount = viewItems.count(); + const int totalCount = viewItems.size(); const QModelIndex index = _index.sibling(_index.row(), 0); const int row = index.row(); const quintptr internalId = index.internalId(); @@ -3637,7 +3637,7 @@ int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const QModelIndex QTreeViewPrivate::modelIndex(int i, int column) const { - if (i < 0 || i >= viewItems.count()) + if (i < 0 || i >= viewItems.size()) return QModelIndex(); QModelIndex ret = viewItems.at(i).index; @@ -3652,7 +3652,7 @@ int QTreeViewPrivate::firstVisibleItem(int *offset) const if (verticalScrollMode == QAbstractItemView::ScrollPerItem) { if (offset) *offset = 0; - return (value < 0 || value >= viewItems.count()) ? -1 : value; + return (value < 0 || value >= viewItems.size()) ? -1 : value; } // ScrollMode == ScrollPerPixel if (uniformRowHeights) { @@ -3664,7 +3664,7 @@ int QTreeViewPrivate::firstVisibleItem(int *offset) const return value / defaultItemHeight; } int y = 0; // ### (maybe do like QHeaderView by letting items have startposition) - for (int i = 0; i < viewItems.count(); ++i) { + for (int i = 0; i < viewItems.size(); ++i) { y += itemHeight(i); // the height value is cached if (y > value) { if (offset) @@ -3685,7 +3685,7 @@ int QTreeViewPrivate::lastVisibleItem(int firstVisual, int offset) const int y = - offset; int value = viewport->height(); - for (int i = firstVisual; i < viewItems.count(); ++i) { + for (int i = firstVisual; i < viewItems.size(); ++i) { y += itemHeight(i); // the height value is cached if (y > value) return i; @@ -3713,11 +3713,11 @@ void QTreeViewPrivate::updateScrollBars() int itemsInViewport = 0; if (uniformRowHeights) { if (defaultItemHeight <= 0) - itemsInViewport = viewItems.count(); + itemsInViewport = viewItems.size(); else itemsInViewport = viewportSize.height() / defaultItemHeight; } else { - const int itemsCount = viewItems.count(); + const int itemsCount = viewItems.size(); const int viewportHeight = viewportSize.height(); for (int height = 0, item = itemsCount - 1; item >= 0; --item) { height += itemHeight(item); @@ -3729,15 +3729,15 @@ void QTreeViewPrivate::updateScrollBars() if (verticalScrollMode == QAbstractItemView::ScrollPerItem) { if (!viewItems.isEmpty()) itemsInViewport = qMax(1, itemsInViewport); - vbar->setRange(0, viewItems.count() - itemsInViewport); + vbar->setRange(0, viewItems.size() - itemsInViewport); vbar->setPageStep(itemsInViewport); vbar->setSingleStep(1); } else { // scroll per pixel int contentsHeight = 0; if (uniformRowHeights) { - contentsHeight = defaultItemHeight * viewItems.count(); + contentsHeight = defaultItemHeight * viewItems.size(); } else { // ### (maybe do like QHeaderView by letting items have startposition) - for (int i = 0; i < viewItems.count(); ++i) + for (int i = 0; i < viewItems.size(); ++i) contentsHeight += itemHeight(i); } vbar->setRange(0, contentsHeight - viewportSize.height()); @@ -3846,7 +3846,7 @@ QList<QPair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topInde QPair<int, int> current; current.first = -2; // -1 is not enough because -1+1 = 0 current.second = -2; - for(int i = 0; i < logicalIndexes.count(); ++i) { + for(int i = 0; i < logicalIndexes.size(); ++i) { const int logicalColumn = logicalIndexes.at(i); if (current.second + 1 != logicalColumn) { if (current.first != -2) { @@ -3922,7 +3922,7 @@ void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bo } if (currentRange.isValid()) selection.append(currentRange); - for (int i = 0; i < rangeStack.count(); ++i) + for (int i = 0; i < rangeStack.size(); ++i) selection.append(rangeStack.at(i)); } q->selectionModel()->select(selection, command); diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index 9449f5f5e9..22f6eaec22 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -196,7 +196,7 @@ public: } inline bool isItemHiddenOrDisabled(int i) const { - if (i < 0 || i >= viewItems.count()) + if (i < 0 || i >= viewItems.size()) return false; const QModelIndex index = viewItems.at(i).index; return isRowHidden(index) || !isIndexEnabled(index); @@ -205,7 +205,7 @@ public: inline int above(int item) const { int i = item; while (isItemHiddenOrDisabled(--item)){} return item < 0 ? i : item; } inline int below(int item) const - { int i = item; while (isItemHiddenOrDisabled(++item)){} return item >= viewItems.count() ? i : item; } + { int i = item; while (isItemHiddenOrDisabled(++item)){} return item >= viewItems.size() ? i : item; } inline void invalidateHeightCache(int item) const { viewItems[item].height = 0; } diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 6df5dffb90..3fa8a7e1b9 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -204,7 +204,7 @@ QModelIndex QTreeModel::index(const QTreeWidgetItem *item, int column) const int row; int guess = item->d->rowGuess; if (guess >= 0 - && par->children.count() > guess + && par->children.size() > guess && par->children.at(guess) == itm) { row = guess; } else { @@ -381,8 +381,8 @@ QMap<int, QVariant> QTreeModel::itemData(const QModelIndex &index) const QTreeWidgetItem *itm = item(index); if (itm) { int column = index.column(); - if (column < itm->values.count()) { - for (int i = 0; i < itm->values.at(column).count(); ++i) { + if (column < itm->values.size()) { + for (int i = 0; i < itm->values.at(column).size(); ++i) { roles.insert(itm->values.at(column).at(i).role, itm->values.at(column).at(i).value); } @@ -451,9 +451,9 @@ bool QTreeModel::insertColumns(int column, int count, const QModelIndex &parent) while (!itemstack.isEmpty()) { QTreeWidgetItem *par = itemstack.pop(); QList<QTreeWidgetItem*> children = par ? par->children : rootItem->children; - for (int row = 0; row < children.count(); ++row) { + for (int row = 0; row < children.size(); ++row) { QTreeWidgetItem *child = children.at(row); - if (child->children.count()) + if (child->children.size()) itemstack.push(child); child->values.insert(column, count, QList<QWidgetItemData>()); } @@ -627,7 +627,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order, else if (oldRow > otherRow && newRow <= otherRow) ++sorting[j].second; } - for (int k = 0; k < newPersistentIndexes.count(); ++k) { + for (int k = 0; k < newPersistentIndexes.size(); ++k) { QModelIndex pi = newPersistentIndexes.at(k); if (pi.parent() != parent) continue; @@ -806,7 +806,7 @@ void QTreeModel::beginRemoveItems(QTreeWidgetItem *parent, int row, int count) if (!parent) parent = rootItem; // now update the iterators - for (int i = 0; i < iterators.count(); ++i) { + for (int i = 0; i < iterators.size(); ++i) { for (int j = 0; j < count; j++) { QTreeWidgetItem *c = parent->child(row + j); iterators[i]->d_func()->ensureValidIterator(c); @@ -827,8 +827,8 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO return; // store the original order of indexes - QList<QPair<QTreeWidgetItem *, int>> sorting(items->count()); - for (int i = 0; i < sorting.count(); ++i) { + QList<QPair<QTreeWidgetItem *, int>> sorting(items->size()); + for (int i = 0; i < sorting.size(); ++i) { sorting[i].first = items->at(i); sorting[i].second = i; } @@ -840,7 +840,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO QModelIndexList fromList; QModelIndexList toList; int colCount = columnCount(); - for (int r = 0; r < sorting.count(); ++r) { + for (int r = 0; r < sorting.size(); ++r) { int oldRow = sorting.at(r).second; if (oldRow == r) continue; @@ -1396,7 +1396,7 @@ QTreeWidgetItem::QTreeWidgetItem(int type) : rtti(type), d(new QTreeWidgetItemPr QTreeWidgetItem::QTreeWidgetItem(const QStringList &strings, int type) : rtti(type), d(new QTreeWidgetItemPrivate(this)) { - for (int i = 0; i < strings.count(); ++i) + for (int i = 0; i < strings.size(); ++i) setText(i, strings.at(i)); } @@ -1432,7 +1432,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *treeview, int type) QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *treeview, const QStringList &strings, int type) : rtti(type), d(new QTreeWidgetItemPrivate(this)) { - for (int i = 0; i < strings.count(); ++i) + for (int i = 0; i < strings.size(); ++i) setText(i, strings.at(i)); // do not set this->view here otherwise insertChild() will fail if (QTreeModel *model = treeModel(treeview)) { @@ -1481,7 +1481,7 @@ QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, int type) QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type) : rtti(type), d(new QTreeWidgetItemPrivate(this)) { - for (int i = 0; i < strings.count(); ++i) + for (int i = 0; i < strings.size(); ++i) setText(i, strings.at(i)); if (parent) parent->addChild(this); @@ -1544,7 +1544,7 @@ QTreeWidgetItem::~QTreeWidgetItem() } // at this point the persistent indexes for the children should also be invalidated // since we invalidated the parent - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QTreeWidgetItem *child = children.at(i); // make sure the child does not try to remove itself from our children list child->par = nullptr; @@ -1652,7 +1652,7 @@ void QTreeWidgetItem::setFlags(Qt::ItemFlags flags) parents.push(this); while (!parents.isEmpty()) { QTreeWidgetItem *parent = parents.pop(); - for (int i = 0; i < parent->children.count(); ++i) { + for (int i = 0; i < parent->children.size(); ++i) { QTreeWidgetItem *child = parent->children.at(i); if (!child->d->disabled) { // if not explicitly disabled parents.push(child); @@ -1681,7 +1681,7 @@ void QTreeWidgetItemPrivate::updateHiddenStatus(QTreeWidgetItem *item, bool inse const QModelIndex index = model->index(parent, 0); item->view->setRowHidden(index.row(), index.parent(), inserting); } - for (int i = 0; i < parent->children.count(); ++i) { + for (int i = 0; i < parent->children.size(); ++i) { QTreeWidgetItem *child = parent->children.at(i); parents.push(child); } @@ -1707,7 +1707,7 @@ void QTreeWidgetItemPrivate::propagateDisabled(QTreeWidgetItem *item) parent->itemChanged(); } - for (int i = 0; i < parent->children.count(); ++i) { + for (int i = 0; i < parent->children.size(); ++i) { QTreeWidgetItem *child = parent->children.at(i); parents.push(child); } @@ -1749,14 +1749,14 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value) switch (role) { case Qt::EditRole: case Qt::DisplayRole: { - if (values.count() <= column) { + if (values.size() <= column) { if (model && this == model->headerItem) model->setColumnCount(column + 1); else values.resize(column + 1); } - if (d->display.count() <= column) { - for (int i = d->display.count() - 1; i < column - 1; ++i) + if (d->display.size() <= column) { + for (int i = d->display.size() - 1; i < column - 1; ++i) d->display.append(QVariant()); d->display.append(value); } else if (d->display[column] != value) { @@ -1767,7 +1767,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value) } break; case Qt::CheckStateRole: if ((itemFlags & Qt::ItemIsAutoTristate) && value != Qt::PartiallyChecked) { - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QTreeWidgetItem *child = children.at(i); if (child->data(column, role).isValid()) {// has a CheckState Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals @@ -1779,10 +1779,10 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value) } Q_FALLTHROUGH(); default: - if (column < values.count()) { + if (column < values.size()) { bool found = false; const QList<QWidgetItemData> column_values = values.at(column); - for (int i = 0; i < column_values.count(); ++i) { + for (int i = 0; i < column_values.size(); ++i) { if (column_values.at(i).role == role) { if (column_values.at(i).value == value) return; // value is unchanged @@ -1823,12 +1823,12 @@ QVariant QTreeWidgetItem::data(int column, int role) const switch (role) { case Qt::EditRole: case Qt::DisplayRole: - if (column >= 0 && column < d->display.count()) + if (column >= 0 && column < d->display.size()) return d->display.at(column); break; case Qt::CheckStateRole: // special case for check state in tristate - if (children.count() && (itemFlags & Qt::ItemIsAutoTristate)) + if (children.size() && (itemFlags & Qt::ItemIsAutoTristate)) return childrenCheckState(column); Q_FALLTHROUGH(); default: @@ -1870,9 +1870,9 @@ void QTreeWidgetItem::read(QDataStream &in) d->display.clear(); in >> values; // move the display value over to the display string list - for (int column = 0; column < values.count(); ++column) { + for (int column = 0; column < values.size(); ++column) { d->display << QVariant(); - for (int i = 0; i < values.at(column).count(); ++i) { + for (int i = 0; i < values.at(column).size(); ++i) { if (values.at(column).at(i).role == Qt::DisplayRole) { d->display[column] = values.at(column).at(i).value; values[column].remove(i--); @@ -1939,8 +1939,8 @@ QTreeWidgetItem &QTreeWidgetItem::operator=(const QTreeWidgetItem &other) void QTreeWidgetItem::addChild(QTreeWidgetItem *child) { if (child) { - insertChild(children.count(), child); - child->d->rowGuess = children.count() - 1; + insertChild(children.size(), child); + child->d->rowGuess = children.size() - 1; } } @@ -1951,7 +1951,7 @@ void QTreeWidgetItem::addChild(QTreeWidgetItem *child) */ void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child) { - if (index < 0 || index > children.count() || child == nullptr || child->view != nullptr || child->par != nullptr) + if (index < 0 || index > children.size() || child == nullptr || child->view != nullptr || child->par != nullptr) return; if (QTreeModel *model = treeModel()) { @@ -1973,7 +1973,7 @@ void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child) QTreeWidgetItem *i = stack.pop(); i->view = view; i->values.reserve(cols); - for (int c = 0; c < i->children.count(); ++c) + for (int c = 0; c < i->children.size(); ++c) stack.push(i->children.at(c)); } children.insert(index, child); @@ -2012,7 +2012,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) model->skipPendingSort = false; model->executePendingSort(); } - if (index >= 0 && index < children.count()) { + if (index >= 0 && index < children.size()) { if (model) model->beginRemoveItems(this, index, 1); d->updateHiddenStatus(children.at(index), false); QTreeWidgetItem *item = children.takeAt(index); @@ -2022,7 +2022,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) while (!stack.isEmpty()) { QTreeWidgetItem *i = stack.pop(); i->view = nullptr; - for (int c = 0; c < i->children.count(); ++c) + for (int c = 0; c < i->children.size(); ++c) stack.push(i->children.at(c)); } d->propagateDisabled(item); @@ -2041,7 +2041,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) */ void QTreeWidgetItem::addChildren(const QList<QTreeWidgetItem*> &children) { - insertChildren(this->children.count(), children); + insertChildren(this->children.size(), children); } /*! @@ -2053,18 +2053,18 @@ void QTreeWidgetItem::addChildren(const QList<QTreeWidgetItem*> &children) */ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &children) { - if (index < 0 || index > this->children.count() || children.isEmpty()) + if (index < 0 || index > this->children.size() || children.isEmpty()) return; if (view && view->isSortingEnabled()) { - for (int n = 0; n < children.count(); ++n) + for (int n = 0; n < children.size(); ++n) insertChild(index, children.at(n)); return; } QTreeModel *model = treeModel(); QStack<QTreeWidgetItem*> stack; QList<QTreeWidgetItem*> itemsToInsert; - for (int n = 0; n < children.count(); ++n) { + for (int n = 0; n < children.size(); ++n) { QTreeWidgetItem *child = children.at(n); if (child->view || child->par) continue; @@ -2084,11 +2084,11 @@ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &c while (!stack.isEmpty()) { QTreeWidgetItem *i = stack.pop(); i->view = view; - for (int c = 0; c < i->children.count(); ++c) + for (int c = 0; c < i->children.size(); ++c) stack.push(i->children.at(c)); } - if (model) model->beginInsertItems(this, index, itemsToInsert.count()); - for (int n = 0; n < itemsToInsert.count(); ++n) { + if (model) model->beginInsertItems(this, index, itemsToInsert.size()); + for (int n = 0; n < itemsToInsert.size(); ++n) { QTreeWidgetItem *child = itemsToInsert.at(n); this->children.insert(index + n, child); if (child->par) @@ -2107,7 +2107,7 @@ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &c QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() { QList<QTreeWidgetItem*> removed; - if (children.count() > 0) { + if (children.size() > 0) { QTreeModel *model = treeModel(); if (model) { // This will trigger a layoutChanged signal, thus we might want to optimize @@ -2116,8 +2116,8 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() // is updated in case we take an item that is selected. model->executePendingSort(); } - if (model) model->beginRemoveItems(this, 0, children.count()); - for (int n = 0; n < children.count(); ++n) { + if (model) model->beginRemoveItems(this, 0, children.size()); + for (int n = 0; n < children.size(); ++n) { QTreeWidgetItem *item = children.at(n); item->par = nullptr; QStack<QTreeWidgetItem*> stack; @@ -2125,7 +2125,7 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() while (!stack.isEmpty()) { QTreeWidgetItem *i = stack.pop(); i->view = nullptr; - for (int c = 0; c < i->children.count(); ++c) + for (int c = 0; c < i->children.size(); ++c) stack.push(i->children.at(c)); } d->propagateDisabled(item); @@ -2375,13 +2375,13 @@ void QTreeWidgetPrivate::_q_selectionChanged(const QItemSelection &selected, con QModelIndexList indices = selected.indexes(); int i; QTreeModel *m = treeModel(); - for (i = 0; i < indices.count(); ++i) { + for (i = 0; i < indices.size(); ++i) { QTreeWidgetItem *item = m->item(indices.at(i)); item->d->selected = true; } indices = deselected.indexes(); - for (i = 0; i < indices.count(); ++i) { + for (i = 0; i < indices.size(); ++i) { QTreeWidgetItem *item = m->item(indices.at(i)); item->d->selected = false; } @@ -2806,10 +2806,10 @@ void QTreeWidget::setHeaderItem(QTreeWidgetItem *item) void QTreeWidget::setHeaderLabels(const QStringList &labels) { Q_D(QTreeWidget); - if (columnCount() < labels.count()) - setColumnCount(labels.count()); + if (columnCount() < labels.size()) + setColumnCount(labels.size()); QTreeWidgetItem *item = d->treeModel()->headerItem; - for (int i = 0; i < labels.count(); ++i) + for (int i = 0; i < labels.size(); ++i) item->setText(i, labels.at(i)); } @@ -3052,8 +3052,8 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const Q_D(const QTreeWidget); const QModelIndexList indexes = selectionModel()->selectedIndexes(); QList<QTreeWidgetItem*> items; - items.reserve(indexes.count()); - QDuplicateTracker<QTreeWidgetItem *> seen(indexes.count()); + items.reserve(indexes.size()); + QDuplicateTracker<QTreeWidgetItem *> seen(indexes.size()); for (const auto &index : indexes) { QTreeWidgetItem *item = d->item(index); if (item->isHidden() || seen.hasSeen(item)) @@ -3206,7 +3206,7 @@ QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem *> &items) const return nullptr; } - for (int c = 0; c < item->values.count(); ++c) { + for (int c = 0; c < item->values.size(); ++c) { const QModelIndex index = indexFromItem(item, c); if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QTreeWidget::mimeData: No index associated with item :" << item; @@ -3285,7 +3285,7 @@ void QTreeWidget::dropEvent(QDropEvent *event) { if (!event->isAccepted() && d->dropOn(event, &row, &col, &topIndex)) { const QList<QModelIndex> idxs = selectedIndexes(); QList<QPersistentModelIndex> indexes; - const int indexesCount = idxs.count(); + const int indexesCount = idxs.size(); indexes.reserve(indexesCount); for (const auto &idx : idxs) indexes.append(idx); @@ -3308,7 +3308,7 @@ void QTreeWidget::dropEvent(QDropEvent *event) { } // insert them back in at their new positions - for (int i = 0; i < indexes.count(); ++i) { + for (int i = 0; i < indexes.size(); ++i) { // Either at a specific point or appended if (row == -1) { if (topIndex.isValid()) { diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index 99f31ee421..fec9d82f60 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -148,8 +148,8 @@ public: executePendingSort(); return children.at(index); } - inline int childCount() const { return children.count(); } - inline int columnCount() const { return values.count(); } + inline int childCount() const { return children.size(); } + inline int columnCount() const { return values.size(); } inline int indexOfChild(QTreeWidgetItem *child) const; void addChild(QTreeWidgetItem *child); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index cf0cbf9a29..2c57e471d0 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2179,7 +2179,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin return false; } - for (int i = 0; i < modalWindowList.count(); ++i) { + for (int i = 0; i < modalWindowList.size(); ++i) { QWindow *modalWindow = modalWindowList.at(i); // A window is not blocked by another modal window if the two are @@ -3381,7 +3381,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) qt_popup_down = nullptr; } - if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup + if (QApplicationPrivate::popupWidgets->size() == 0) { // this was the last popup delete QApplicationPrivate::popupWidgets; QApplicationPrivate::popupWidgets = nullptr; qt_popup_down_closed = false; @@ -3426,7 +3426,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) // can become nullptr due to setFocus() above if (QApplicationPrivate::popupWidgets && - QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard + QApplicationPrivate::popupWidgets->size() == 1) // grab mouse/keyboard grabForPopup(aw); } @@ -3441,7 +3441,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) popupWidgets = new QWidgetList; popupWidgets->append(popup); // add to end of list - if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard + if (QApplicationPrivate::popupWidgets->size() == 1) // grab mouse/keyboard grabForPopup(popup); // popups are not focus-handled by the window system (the first @@ -3449,7 +3449,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) // new popup gets the focus if (popup->focusWidget()) { popup->focusWidget()->setFocus(Qt::PopupFocusReason); - } else if (popupWidgets->count() == 1) { // this was the first popup + } else if (popupWidgets->size() == 1) { // this was the first popup if (QWidget *fw = QApplication::focusWidget()) { QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); QCoreApplication::sendEvent(fw, &e); diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index d16d903f53..501883e85a 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -233,7 +233,7 @@ void QBoxLayoutPrivate::setupGeom() hasHfw = false; - int n = list.count(); + int n = list.size(); geomArray.clear(); QList<QLayoutStruct> a(n); @@ -365,7 +365,7 @@ void QBoxLayoutPrivate::setupGeom() void QBoxLayoutPrivate::calcHfw(int w) { QList<QLayoutStruct> &a = geomArray; - int n = a.count(); + int n = a.size(); int h = 0; int mh = 0; @@ -411,9 +411,9 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item) int QBoxLayoutPrivate::validateIndex(int index) const { if (index < 0) - return list.count(); // append + return list.size(); // append - Q_ASSERT_X(index >= 0 && index <= list.count(), "QBoxLayout::insert", "index out of range"); + Q_ASSERT_X(index >= 0 && index <= list.size(), "QBoxLayout::insert", "index out of range"); return index; } @@ -680,7 +680,7 @@ void QBoxLayout::invalidate() int QBoxLayout::count() const { Q_D(const QBoxLayout); - return d->list.count(); + return d->list.size(); } /*! @@ -689,7 +689,7 @@ int QBoxLayout::count() const QLayoutItem *QBoxLayout::itemAt(int index) const { Q_D(const QBoxLayout); - return index >= 0 && index < d->list.count() ? d->list.at(index)->item : nullptr; + return index >= 0 && index < d->list.size() ? d->list.at(index)->item : nullptr; } /*! @@ -698,7 +698,7 @@ QLayoutItem *QBoxLayout::itemAt(int index) const QLayoutItem *QBoxLayout::takeAt(int index) { Q_D(QBoxLayout); - if (index < 0 || index >= d->list.count()) + if (index < 0 || index >= d->list.size()) return nullptr; QBoxLayoutItem *b = d->list.takeAt(index); QLayoutItem *item = b->item; @@ -749,7 +749,7 @@ void QBoxLayout::setGeometry(const QRect &r) QList<QLayoutStruct> a = d->geomArray; int pos = horz(d->dir) ? s.x() : s.y(); int space = horz(d->dir) ? s.width() : s.height(); - int n = a.count(); + int n = a.size(); if (d->hasHfw && !horz(d->dir)) { for (int i = 0; i < n; i++) { QBoxLayoutItem *box = d->list.at(i); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index fdce766c93..e924c71997 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1643,7 +1643,7 @@ void QFormLayout::addItem(QLayoutItem *item) int QFormLayout::count() const { Q_D(const QFormLayout); - return d->m_things.count(); + return d->m_things.size(); } /*! diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index c3fb7d6993..7998567a21 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -109,18 +109,18 @@ public: int minimumHeightForWidth(int width, int hSpacing, int vSpacing); inline void getNextPos(int &row, int &col) { row = nextR; col = nextC; } - inline int count() const { return things.count(); } + inline int count() const { return things.size(); } QRect cellRect(int row, int col) const; inline QLayoutItem *itemAt(int index) const { - if (index >= 0 && index < things.count()) + if (index >= 0 && index < things.size()) return things.at(index)->item(); else return nullptr; } inline QLayoutItem *takeAt(int index) { Q_Q(QGridLayout); - if (index >= 0 && index < things.count()) { + if (index >= 0 && index < things.size()) { if (QGridBox *b = things.takeAt(index)) { QLayoutItem *item = b->takeItem(); if (QLayout *l = item->layout()) { @@ -148,7 +148,7 @@ public: } void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const { - if (index >= 0 && index < things.count()) { + if (index >= 0 && index < things.size()) { const QGridBox *b = things.at(index); int toRow = b->toRow(rr); int toCol = b->toCol(cc); @@ -1294,7 +1294,7 @@ QLayoutItem *QGridLayout::itemAt(int index) const QLayoutItem *QGridLayout::itemAtPosition(int row, int column) const { Q_D(const QGridLayout); - int n = d->things.count(); + int n = d->things.size(); for (int i = 0; i < n; ++i) { QGridBox *box = d->things.at(i); if (row >= box->row && row <= box->toRow(d->rr) diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 78177aa0cd..aca470fe1c 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -166,7 +166,7 @@ QStackedLayout::~QStackedLayout() int QStackedLayout::addWidget(QWidget *widget) { Q_D(QStackedLayout); - return insertWidget(d->list.count(), widget); + return insertWidget(d->list.size(), widget); } /*! @@ -187,9 +187,9 @@ int QStackedLayout::insertWidget(int index, QWidget *widget) { Q_D(QStackedLayout); addChildWidget(widget); - index = qMin(index, d->list.count()); + index = qMin(index, d->list.size()); if (index < 0) - index = d->list.count(); + index = d->list.size(); QWidgetItem *wi = QLayoutPrivate::createWidgetItem(this, widget); d->list.insert(index, wi); invalidate(); @@ -234,8 +234,8 @@ QLayoutItem *QStackedLayout::takeAt(int index) QLayoutItem *item = d->list.takeAt(index); if (index == d->index) { d->index = -1; - if ( d->list.count() > 0 ) { - int newIndex = (index == d->list.count()) ? index-1 : index; + if ( d->list.size() > 0 ) { + int newIndex = (index == d->list.size()) ? index-1 : index; setCurrentIndex(newIndex); } else { emit currentChanged(-1); @@ -403,7 +403,7 @@ QSize QStackedLayout::sizeHint() const { Q_D(const QStackedLayout); QSize s(0, 0); - int n = d->list.count(); + int n = d->list.size(); for (int i = 0; i < n; ++i) if (QWidget *widget = d->list.at(i)->widget()) { @@ -424,7 +424,7 @@ QSize QStackedLayout::minimumSize() const { Q_D(const QStackedLayout); QSize s(0, 0); - int n = d->list.count(); + int n = d->list.size(); for (int i = 0; i < n; ++i) if (QWidget *widget = d->list.at(i)->widget()) @@ -444,7 +444,7 @@ void QStackedLayout::setGeometry(const QRect &rect) widget->setGeometry(rect); break; case StackAll: - if (const int n = d->list.count()) + if (const int n = d->list.size()) for (int i = 0; i < n; ++i) if (QWidget *widget = d->list.at(i)->widget()) widget->setGeometry(rect); @@ -531,7 +531,7 @@ void QStackedLayout::setStackingMode(StackingMode stackingMode) return; d->stackingMode = stackingMode; - const int n = d->list.count(); + const int n = d->list.size(); if (n == 0) return; diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index b831c5265a..3166613199 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -157,7 +157,7 @@ QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int mse void QTipLabel::restartExpireTimer(int msecDisplayTime) { - int time = 10000 + 40 * qMax(0, text().length()-100); + int time = 10000 + 40 * qMax(0, text().size()-100); if (msecDisplayTime > 0) time = msecDisplayTime; expireTimer.start(time, this); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index f89e6082c9..713986ebde 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -3133,7 +3133,7 @@ void QWidget::addAction(QAction *action) */ void QWidget::addActions(const QList<QAction *> &actions) { - for(int i = 0; i < actions.count(); i++) + for(int i = 0; i < actions.size(); i++) insertAction(nullptr, actions.at(i)); } @@ -3182,7 +3182,7 @@ void QWidget::insertAction(QAction *before, QAction *action) */ void QWidget::insertActions(QAction *before, const QList<QAction*> &actions) { - for(int i = 0; i < actions.count(); ++i) + for(int i = 0; i < actions.size(); ++i) insertAction(before, actions.at(i)); } @@ -9036,7 +9036,7 @@ bool QWidget::event(QEvent *event) break; #if QT_CONFIG(menu) case Qt::ActionsContextMenu: - if (d->actions.count()) { + if (d->actions.size()) { QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), nullptr, this); break; @@ -9266,7 +9266,7 @@ bool QWidget::event(QEvent *event) break; case QEvent::DynamicPropertyChange: { const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); - if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) { + if (propName.size() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) { uint value = property(propName.constData()).toUInt(); if (!d->extra) d->createExtra(); diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index 1f2fa5dea3..4a3fb2be89 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -82,7 +82,7 @@ QWidgetAction::QWidgetAction(QObject *parent) QWidgetAction::~QWidgetAction() { Q_D(QWidgetAction); - for (int i = 0; i < d->createdWidgets.count(); ++i) + for (int i = 0; i < d->createdWidgets.size(); ++i) disconnect(d->createdWidgets.at(i), SIGNAL(destroyed(QObject*)), this, SLOT(_q_widgetDestroyed(QObject*))); QList<QWidget *> widgetsToDelete = d->createdWidgets; @@ -190,7 +190,7 @@ bool QWidgetAction::event(QEvent *event) if (event->type() == QEvent::ActionChanged) { if (d->defaultWidget) d->defaultWidget->setEnabled(isEnabled()); - for (int i = 0; i < d->createdWidgets.count(); ++i) + for (int i = 0; i < d->createdWidgets.size(); ++i) d->createdWidgets.at(i)->setEnabled(isEnabled()); } return QAction::event(event); diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 0ab09a26f2..c9b52e125b 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -302,7 +302,7 @@ void QWidgetRepaintManager::removeDirtyWidget(QWidget *w) needsFlushWidgets.removeAll(w); QWidgetPrivate *wd = w->d_func(); - const int n = wd->children.count(); + const int n = wd->children.size(); for (int i = 0; i < n; ++i) { if (QWidget *child = qobject_cast<QWidget*>(wd->children.at(i))) removeDirtyWidget(child); @@ -808,7 +808,7 @@ void QWidgetRepaintManager::paintAndFlush() // texture content changes. Check if we have such widgets in the special // dirty list. QVarLengthArray<QWidget *, 16> paintPending; - const int numPaintPending = dirtyRenderToTextureWidgets.count(); + const int numPaintPending = dirtyRenderToTextureWidgets.size(); paintPending.reserve(numPaintPending); for (int i = 0; i < numPaintPending; ++i) { QWidget *w = dirtyRenderToTextureWidgets.at(i); @@ -850,7 +850,7 @@ void QWidgetRepaintManager::paintAndFlush() } } } - for (int i = 0; i < dirtyRenderToTextureWidgets.count(); ++i) + for (int i = 0; i < dirtyRenderToTextureWidgets.size(); ++i) resetWidget(dirtyRenderToTextureWidgets.at(i)); dirtyRenderToTextureWidgets.clear(); @@ -1133,7 +1133,7 @@ QRegion QWidgetRepaintManager::staticContents(QWidget *parent, const QRect &with return region; const bool clipToRect = !withinClipRect.isEmpty(); - const int count = staticWidgets.count(); + const int count = staticWidgets.size(); for (int i = 0; i < count; ++i) { QWidget *w = staticWidgets.at(i); QWidgetPrivate *wd = w->d_func(); diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 5ebe6c491b..4e84c21c0f 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -714,7 +714,7 @@ static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleH static QList<QVariant> subControlLayout(const QString& layout) { QList<QVariant> buttons; - for (int i = 0; i < layout.length(); i++) { + for (int i = 0; i < layout.size(); i++) { int button = layout[i].toLatin1(); switch (button) { case 'm': @@ -980,7 +980,7 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject * palette = QToolTip::palette(); #endif - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration& decl = declarations.at(i); if (decl.d->propertyId == BorderImage) { QString uri; @@ -1056,7 +1056,7 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject * } else if (hintName.endsWith("icon"_L1)) { hintValue = decl.iconValue(); } else if (hintName == "button-layout"_L1 - && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) { + && decl.d->values.size() != 0 && decl.d->values.at(0).type == Value::String) { hintValue = subControlLayout(decl.d->values.at(0).variant.toString()); } else { int integer; @@ -1601,7 +1601,7 @@ public: #endif do { const ushort *uc = (const ushort *)nodeName.constData(); - const ushort *e = uc + nodeName.length(); + const ushort *e = uc + nodeName.size(); const uchar *c = (const uchar *)metaObject->className(); while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) { ++uc; @@ -1698,8 +1698,8 @@ QList<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const objectSs.append(ss); } - for (int i = 0; i < objectSs.count(); i++) - objectSs[i].depth = objectSs.count() - i + 2; + for (int i = 0; i < objectSs.size(); i++) + objectSs[i].depth = objectSs.size() - i + 2; styleSelector.styleSheets += objectSs; @@ -1716,7 +1716,7 @@ static QList<Declaration> declarations(const QList<StyleRule> &styleRules, const quint64 pseudoClass = PseudoClass_Unspecified) { QList<Declaration> decls; - for (int i = 0; i < styleRules.count(); i++) { + for (int i = 0; i < styleRules.size(); i++) { const Selector& selector = styleRules.at(i).selectors.at(0); // Rules with pseudo elements don't cascade. This is an intentional // diversion for CSS @@ -1846,7 +1846,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint6 quint64 stateMask = 0; const QList<StyleRule> rules = styleRules(obj); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); quint64 negated = 0; stateMask |= selector.pseudoClass(&negated); @@ -2168,7 +2168,7 @@ bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const } QString pseudoElement = QLatin1StringView(knownPseudoElements[part].name); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) { cache[part] = true; @@ -2639,7 +2639,7 @@ void QStyleSheetStyle::setProperties(QWidget *w) { // scan decls for final occurrence of each "qproperty" QDuplicateTracker<QString> propertySet(decls.size()); - for (int i = decls.count() - 1; i >= 0; --i) { + for (int i = decls.size() - 1; i >= 0; --i) { const QString property = decls.at(i).d->property; if (!property.startsWith("qproperty-"_L1, Qt::CaseInsensitive)) continue; @@ -2648,7 +2648,7 @@ void QStyleSheetStyle::setProperties(QWidget *w) } } - for (int i = finals.count() - 1; i >= 0; --i) { + for (int i = finals.size() - 1; i >= 0; --i) { const Declaration &decl = decls.at(finals[i]); QStringView property = decl.d->property; property = property.mid(10); // strip "qproperty-" @@ -2900,7 +2900,7 @@ void QStyleSheetStyle::polish(QWidget *w) //set the WA_Hover attribute if one of the selector depends of the hover state QList<StyleRule> rules = styleRules(w); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); quint64 negated = 0; quint64 cssClass = selector.pseudoClass(&negated); @@ -3488,7 +3488,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC QStyleOptionComplex optCopy(*opt); optCopy.subControls = { }; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) @@ -5469,7 +5469,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op layout = subControlLayout("mNX"_L1); int width = 0, height = 0; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) @@ -6036,7 +6036,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp int x = 0, width = 0; QRenderRule subRule; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index abf3566e1c..1b519bf4c5 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -326,7 +326,7 @@ int QCompletionModel::rowCount(const QModelIndex &parent) const if (showAll) { // Show all items below current parent, even if we have no valid matches - if (engine->curParts.count() != 1 && !engine->matchCount() + if (engine->curParts.size() != 1 && !engine->matchCount() && !engine->curParent.isValid()) return 0; return d->model->rowCount(engine->curParent); @@ -411,7 +411,7 @@ void QCompletionEngine::filter(const QStringList& parts) return; QModelIndex parent; - for (int i = 0; i < curParts.count() - 1; i++) { + for (int i = 0; i < curParts.size() - 1; i++) { QString part = curParts.at(i); int emi = filter(part, parent, -1).exactMatchIndex; if (emi == -1) @@ -432,7 +432,7 @@ void QCompletionEngine::filter(const QStringList& parts) QMatchData QCompletionEngine::filterHistory() { QAbstractItemModel *source = c->proxy->sourceModel(); - if (curParts.count() <= 1 || c->proxy->showAll || !source) + if (curParts.size() <= 1 || c->proxy->showAll || !source) return QMatchData(); #if QT_CONFIG(filesystemmodel) @@ -516,7 +516,7 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin(); while (it1 != cache.end()) { CacheItem& ci = it1.value(); - int sz = ci.count()/2; + int sz = ci.size()/2; QMap<QString, QMatchData>::iterator it2 = ci.begin(); int i = 0; while (it2 != ci.end() && i < sz) { @@ -524,7 +524,7 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con it2 = ci.erase(it2); i++; } - if (ci.count() == 0) { + if (ci.size() == 0) { it1 = cache.erase(it1); } else { ++it1; @@ -1811,7 +1811,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const } while (idx.isValid()); #if !defined(Q_OS_WIN) - if (list.count() == 1) // only the separator or some other text + if (list.size() == 1) // only the separator or some other text return list[0]; list[0].clear() ; // the join below will provide the separator #endif diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 1cd001b4c1..b74de04031 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -78,7 +78,7 @@ public: QIndexMapper(int f, int t) : v(false), f(f), t(t) { } QIndexMapper(const QList<int> &vec) : v(true), vector(vec), f(-1), t(-1) { } - inline int count() const { return v ? vector.count() : t - f + 1; } + inline int count() const { return v ? vector.size() : t - f + 1; } inline int operator[] (int index) const { return v ? vector[index] : f + index; } inline int indexOf(int x) const { return v ? vector.indexOf(x) : ((t < f) ? -1 : x - f); } inline bool isValid() const { return !isEmpty(); } @@ -88,7 +88,7 @@ public: inline int last() const { return v ? vector.last() : t; } inline int from() const { Q_ASSERT(!v); return f; } inline int to() const { Q_ASSERT(!v); return t; } - inline int cost() const { return vector.count()+2; } + inline int cost() const { return vector.size()+2; } private: bool v; diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 133878f691..71a515a1cd 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -520,14 +520,14 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, inputType = QScroller::InputMove; if (te->pointingDevice()->type() == QInputDevice::DeviceType::TouchPad) { - if (te->points().count() != 2) // 2 fingers on pad + if (te->points().size() != 2) // 2 fingers on pad return Ignore; point = te->points().at(0).scenePressPosition() + ((te->points().at(0).scenePosition() - te->points().at(0).scenePressPosition()) + (te->points().at(1).scenePosition() - te->points().at(1).scenePressPosition())) / 2; } else { // TouchScreen - if (te->points().count() != 1) // 1 finger on screen + if (te->points().size() != 1) // 1 finger on screen return Ignore; point = te->points().at(0).scenePosition(); diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index e69b19feb1..c781df364a 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1382,10 +1382,10 @@ bool QScrollerPrivate::prepareScrolling(const QPointF &position) // - check if the content position was moved if (contentDelta != QPointF(0, 0)) { // need to correct all segments - for (int i = 0; i < xSegments.count(); i++) + for (int i = 0; i < xSegments.size(); i++) xSegments[i].startPos -= contentDelta.x(); - for (int i = 0; i < ySegments.count(); i++) + for (int i = 0; i < ySegments.size(); i++) ySegments[i].startPos -= contentDelta.y(); } diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 122d81e1ed..bac4a29cff 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -180,10 +180,10 @@ QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const Q_Q(const QAbstractButton); QList<QAbstractButton *> buttonList = queryButtonList(); - if (!autoExclusive || buttonList.count() == 1) // no group + if (!autoExclusive || buttonList.size() == 1) // no group return nullptr; - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *b = buttonList.at(i); if (b->d_func()->checked && b != q) return b; @@ -227,7 +227,7 @@ void QAbstractButtonPrivate::moveFocus(int key) QPoint goal = target.center(); uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus; - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *button = buttonList.at(i); if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() && (exclusive || (button->focusPolicy() & focus_flag) == focus_flag)) { @@ -310,7 +310,7 @@ void QAbstractButtonPrivate::fixFocusPolicy() return; QList<QAbstractButton *> buttonList = queryButtonList(); - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *b = buttonList.at(i); if (!b->isCheckable()) continue; diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 7fd94e6201..91fedea650 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -368,7 +368,7 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol #if QT_CONFIG(itemviews) if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) { const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>(); - if (headers.count() <= 2) { + if (headers.size() <= 2) { for (const QHeaderView *header : headers) { const QRect geo = header->geometry(); if (header->orientation() == Qt::Vertical && header->isVisible() && QStyle::visualRect(opt.direction, opt.rect, geo).left() <= opt.rect.width() / 2) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index ff41a72fca..c168b3d990 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1952,7 +1952,7 @@ QValidator::State QSpinBoxValidator::validate(QString &input, int &pos) const if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { input.prepend(dptr->prefix); - pos += dptr->prefix.length(); + pos += dptr->prefix.size(); } if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix)) diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index bd0c959396..3a992fed74 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -14,7 +14,7 @@ void QButtonGroupPrivate::detectCheckedButton() checkedButton = nullptr; if (exclusive) return; - for (int i = 0; i < buttonList.count(); i++) { + for (int i = 0; i < buttonList.size(); i++) { if (buttonList.at(i) != previous && buttonList.at(i)->isChecked()) { checkedButton = buttonList.at(i); return; @@ -82,7 +82,7 @@ QButtonGroup::QButtonGroup(QObject *parent) QButtonGroup::~QButtonGroup() { Q_D(QButtonGroup); - for (int i = 0; i < d->buttonList.count(); ++i) + for (int i = 0; i < d->buttonList.size(); ++i) d->buttonList.at(i)->d_func()->group = nullptr; } diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 42ef8c4a35..4d3360226f 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -72,7 +72,7 @@ QString QCalendarDateSectionValidator::highlightString(const QString &str, int p { if (pos == 0) return "<b>"_L1 + str + "</b>"_L1; - int startPos = str.length() - pos; + int startPos = str.size() - pos; return QStringView{str}.mid(0, startPos) + "<b>"_L1 + QStringView{str}.mid(startPos, pos) + "</b>"_L1; } @@ -728,7 +728,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) if (m_widget) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent* ke = (QKeyEvent*)e; - if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { + if ((ke->text().size() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { applyDate(); emit editingFinished(); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 7c5de0e2cb..330bcb6a39 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2298,7 +2298,7 @@ void QComboBox::insertItems(int index, const QStringList &list) if (list.isEmpty()) return; index = qBound(0, index, count()); - int insertCount = qMin(d->maxCount - index, list.count()); + int insertCount = qMin(d->maxCount - index, list.size()); if (insertCount <= 0) return; // For the common case where we are using the built in QStandardItemModel diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 897e0dce06..e7b644a67b 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1830,7 +1830,7 @@ int QDateTimeEditPrivate::sectionAt(int pos) const const int textSize = text.size(); if (textSize - pos < separators.last().size() + 1) { if (separators.last().size() == 0) { - return sectionNodes.count() - 1; + return sectionNodes.size() - 1; } return (pos == textSize ? LastSectionIndex : NoSectionIndex); } diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 8d874aaa03..1f8bdc0f94 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -185,8 +185,8 @@ void QDialogButtonBoxPrivate::resetLayout() void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse) { - int start = reverse ? buttonList.count() - 1 : 0; - int end = reverse ? -1 : buttonList.count(); + int start = reverse ? buttonList.size() - 1 : 0; + int end = reverse ? -1 : buttonList.size(); int step = reverse ? -1 : 1; for (int i = start; i != end; i += step) { @@ -636,7 +636,7 @@ void QDialogButtonBox::clear() d->standardButtonHash.clear(); for (int i = 0; i < NRoles; ++i) { QList<QAbstractButton *> &list = d->buttonLists[i]; - while (list.count()) { + while (list.size()) { QAbstractButton *button = list.takeAt(0); QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed())); delete button; @@ -655,7 +655,7 @@ QList<QAbstractButton *> QDialogButtonBox::buttons() const QList<QAbstractButton *> finalList; for (int i = 0; i < NRoles; ++i) { const QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) + for (int j = 0; j < list.size(); ++j) finalList.append(list.at(j)); } return finalList; @@ -672,7 +672,7 @@ QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *butto Q_D(const QDialogButtonBox); for (int i = 0; i < NRoles; ++i) { const QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) { + for (int j = 0; j < list.size(); ++j) { if (list.at(j) == button) return ButtonRole(i); } @@ -696,7 +696,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) d->standardButtonHash.remove(reinterpret_cast<QPushButton *>(button)); for (int i = 0; i < NRoles; ++i) { QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) { + for (int j = 0; j < list.size(); ++j) { if (list.at(j) == button) { list.takeAt(j); if (!d->internalRemove) { diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index cec1d1bc14..91737b301a 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -91,7 +91,7 @@ bool QDockAreaLayoutItem::skip() const return widgetItem->isEmpty(); if (subinfo != nullptr) { - for (int i = 0; i < subinfo->item_list.count(); ++i) { + for (int i = 0; i < subinfo->item_list.size(); ++i) { if (!subinfo->item_list.at(i).skip()) return false; } @@ -852,7 +852,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, delta = growlimit; int d = 0; - for (int i = index + 1; d < delta && i < list.count(); ++i) + for (int i = index + 1; d < delta && i < list.size(); ++i) d += shrink(list[i], delta - d); delta = d; d = 0; @@ -860,7 +860,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, d += grow(list[i], delta - d); } else if (delta < 0) { int growlimit = 0; - for (int i = index + 1; i < list.count(); ++i) { + for (int i = index + 1; i < list.size(); ++i) { const QLayoutStruct &ls = list.at(i); if (ls.empty) continue; @@ -878,7 +878,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, d += shrink(list[i], -delta - d); delta = -d; d = 0; - for (int i = index + 1; d < -delta && i < list.count(); ++i) + for (int i = index + 1; d < -delta && i < list.size(); ++i) d += grow(list[i], -delta - d); } @@ -949,12 +949,12 @@ void QDockAreaLayoutInfo::unnest(int index) QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == nullptr) return; - if (item.subinfo->item_list.count() > 1) + if (item.subinfo->item_list.size() > 1) return; - if (item.subinfo->item_list.count() == 0) { + if (item.subinfo->item_list.size() == 0) { item_list.removeAt(index); - } else if (item.subinfo->item_list.count() == 1) { + } else if (item.subinfo->item_list.size() == 1) { QDockAreaLayoutItem &child = item.subinfo->item_list.first(); if (child.widgetItem != nullptr) { item.widgetItem = child.widgetItem; @@ -974,7 +974,7 @@ void QDockAreaLayoutInfo::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - if (path.count() > 1) { + if (path.size() > 1) { const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); @@ -994,7 +994,7 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) if (index < 0) index = -index - 1; - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->plug(path.mid(1)); @@ -1013,7 +1013,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->unplug(path.mid(1)); @@ -1103,7 +1103,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == nullptr @@ -1185,7 +1185,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid break; } } else { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -1224,7 +1224,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -1251,9 +1251,9 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) int index = path.first(); if (index < 0) index = -index - 1; - if (index >= item_list.count()) + if (index >= item_list.size()) return this; - if (path.count() == 1 || item_list[index].subinfo == nullptr) + if (path.size() == 1 || item_list[index].subinfo == nullptr) return this; return item_list[index].subinfo->info(path.mid(1)); } @@ -1308,7 +1308,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != nullptr); return item.subinfo->itemRect(path.mid(1)); @@ -1341,7 +1341,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != nullptr); return item.subinfo->separatorRect(path.mid(1)); @@ -1566,7 +1566,7 @@ QRegion QDockAreaLayoutInfo::separatorRegion() const return result; #endif - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -1596,7 +1596,7 @@ void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget, return; #endif - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -1681,7 +1681,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->item(path.mid(1)); @@ -1691,7 +1691,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.placeHolderItem != nullptr) continue; @@ -1708,7 +1708,7 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.placeHolderItem != nullptr) continue; @@ -1733,7 +1733,7 @@ QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) void QDockAreaLayoutInfo::deleteAllLayoutItems() { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item= item_list[i]; if (item.subinfo) { item.subinfo->deleteAllLayoutItems(); @@ -1753,7 +1753,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const // write the index in item_list of the widget that's currently on top. quintptr id = currentTabId(); int index = -1; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (tabId(item_list.at(i)) == id) { index = i; break; @@ -1766,9 +1766,9 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const stream << (uchar) SequenceMarker; } - stream << (uchar) o << int(item_list.count()); + stream << (uchar) o << int(item_list.size()); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.widgetItem != nullptr) { stream << (uchar) WidgetMarker; @@ -1864,7 +1864,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } QDockWidget *widget = nullptr; - for (int j = 0; j < widgets.count(); ++j) { + for (int j = 0; j < widgets.size(); ++j) { if (widgets.at(j)->objectName() == name) { widget = widgets.takeAt(j); break; @@ -1950,7 +1950,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } #if QT_CONFIG(tabbar) - if (!testing && tabbed && index >= 0 && index < item_list.count()) { + if (!testing && tabbed && index >= 0 && index < item_list.size()) { updateTabBar(); setCurrentTabId(tabId(item_list.at(index))); } @@ -1970,7 +1970,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const } int j = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -2022,7 +2022,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) if (tabBar) tabBar->setParent(parent); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.flags & QDockAreaLayoutItem::GapItem) continue; @@ -2062,7 +2062,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const const quintptr oldCurrentId = currentTabId(); int tab_idx = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -2127,7 +2127,7 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) if (tabBar != nullptr) tabBar->setShape(static_cast<QTabBar::Shape>(shape)); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.subinfo != nullptr) item.subinfo->setTabBarShape(shape); @@ -2159,7 +2159,7 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const result.insert(tabBar); } - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.subinfo != nullptr) result += item.subinfo->usedTabBars(); @@ -2173,13 +2173,13 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const { QSet<QWidget*> result; - const int numSeparatorWidgets = separatorWidgets.count(); + const int numSeparatorWidgets = separatorWidgets.size(); result.reserve(numSeparatorWidgets); for (int i = 0; i < numSeparatorWidgets; ++i) result << separatorWidgets.at(i); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.subinfo != nullptr) result += item.subinfo->usedSeparatorWidgets(); @@ -2226,7 +2226,7 @@ int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const { Q_ASSERT(tabbed && tabBar); quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex)); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (tabId(item_list.at(i)) == data) return i; } @@ -2490,7 +2490,7 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.count() == 1) + if (path.size() == 1) return &docks[index]; return docks[index].info(path.mid(1)); @@ -2545,7 +2545,7 @@ QRect QDockAreaLayout::separatorRect(const QList<int> &path) const const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.count() == 1) + if (path.size() == 1) return separatorRect(index); else return docks[index].separatorRect(path.mid(1)); @@ -3043,7 +3043,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do { QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget); QDockAreaLayoutInfo &info = docks[pos]; - if (orientation == info.o || info.item_list.count() <= 1) { + if (orientation == info.o || info.item_list.size() <= 1) { // empty dock areas, or dock areas containing exactly one widget can have their orientation // switched. info.o = orientation; @@ -3089,11 +3089,11 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o) { - if (Q_UNLIKELY(docks.count() != sizes.count())) { + if (Q_UNLIKELY(docks.size() != sizes.size())) { qWarning("QMainWidget::resizeDocks: size of the lists are not the same"); return; } - int count = docks.count(); + int count = docks.size(); fallbackToSizeHints = false; for (int i = 0; i < count; ++i) { QList<int> path = indexOf(docks[i]); @@ -3206,7 +3206,7 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or int delta = 0; int index = separator.last(); - if (separator.count() > 1) { + if (separator.size() > 1) { QDockAreaLayoutInfo *info = this->info(separator); delta = pick(info->o, dest - origin); if (delta != 0) @@ -3347,7 +3347,7 @@ QSet<QTabBar*> QDockAreaLayout::usedTabBars() const QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const { QSet<QWidget*> result; - const int numSeparators = separatorWidgets.count(); + const int numSeparators = separatorWidgets.size(); result.reserve(numSeparators); for (int i = 0; i < numSeparators; ++i) result << separatorWidgets.at(i); @@ -3365,7 +3365,7 @@ QRect QDockAreaLayout::gapRect(const QList<int> &path) const if (info == nullptr) return QRect(); int index = path.last(); - if (index < 0 || index >= info->item_list.count()) + if (index < 0 || index >= info->item_list.size()) return QRect(); return info->itemRect(index, true); } diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 2b253ce2b7..67bb099446 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -277,7 +277,7 @@ void QDockWidgetLayout::addItem(QLayoutItem*) QLayoutItem *QDockWidgetLayout::itemAt(int index) const { int cnt = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QLayoutItem *item = item_list.at(i); if (item == nullptr) continue; @@ -290,7 +290,7 @@ QLayoutItem *QDockWidgetLayout::itemAt(int index) const QLayoutItem *QDockWidgetLayout::takeAt(int index) { int j = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QLayoutItem *item = item_list.at(i); if (item == nullptr) continue; @@ -307,7 +307,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) int QDockWidgetLayout::count() const { int result = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (item_list.at(i)) ++result; } @@ -1577,7 +1577,7 @@ bool QDockWidget::event(QEvent *event) bool onTop = false; if (win != nullptr) { const QObjectList &siblings = win->children(); - onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; + onTop = siblings.size() > 0 && siblings.last() == (QObject*)this; } #if QT_CONFIG(tabbar) if (!isFloating() && layout != nullptr && onTop) diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index c4239e70ca..a7f31995e1 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -132,13 +132,13 @@ static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool return system; } - if (writingSystems.count() == 1 && system > QFontDatabase::Cyrillic) + if (writingSystems.size() == 1 && system > QFontDatabase::Cyrillic) return system; - if (writingSystems.count() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese) + if (writingSystems.size() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese) return system; - if (writingSystems.count() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean) + if (writingSystems.size() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean) return system; return QFontDatabase::Any; @@ -317,7 +317,7 @@ void QFontComboBoxPrivate::_q_updateModel() } result += list.at(i); if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + " ["_L1)) - offset = result.count() - 1; + offset = result.size() - 1; } list = result; diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 6f49b831ad..eef2685569 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -149,7 +149,7 @@ static QString int2string(int num, int base, int ndigits, bool *oflow) break; } if (negative) { - for (int i=0; i<(int)s.length(); i++) { + for (int i=0; i<(int)s.size(); i++) { if (s[i] != u' ') { if (i != 0) { s[i-1] = u'-'; @@ -161,7 +161,7 @@ static QString int2string(int num, int base, int ndigits, bool *oflow) } } if (oflow) - *oflow = (int)s.length() > ndigits; + *oflow = (int)s.size() > ndigits; return s; } @@ -186,10 +186,10 @@ static QString double2string(double num, int base, int ndigits, bool *oflow) s[i] = u' '; s[i+1] = u'e'; } - } while (nd-- && (int)s.length() > ndigits); + } while (nd-- && (int)s.size() > ndigits); } if (oflow) - *oflow = (int)s.length() > ndigits; + *oflow = (int)s.size() > ndigits; return s; } @@ -679,7 +679,7 @@ void QLCDNumberPrivate::internalSetString(const QString& s) Q_Q(QLCDNumber); QString buffer(ndigits, QChar()); int i; - int len = s.length(); + int len = s.size(); QBitArray newPoints(ndigits); if (!smallPoint) { diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index b87d7e09cc..c38f3db7a1 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1611,7 +1611,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) if (d->control->composeMode()) { int preeditPos = d->control->cursor(); int posInPreedit = position - d->control->cursor(); - int preeditLength = d->control->preeditAreaText().length(); + int preeditLength = d->control->preeditAreaText().size(); bool positionOnPreedit = false; if (posInPreedit >= 0 && posInPreedit <= preeditLength) @@ -2123,13 +2123,13 @@ void QLineEdit::dropEvent(QDropEvent* e) if (e->source() == this) { if (e->dropAction() == Qt::MoveAction) { if (selStart > oldSelStart && selStart <= oldSelEnd) - setSelection(oldSelStart, str.length()); + setSelection(oldSelStart, str.size()); else if (selStart > oldSelEnd) - setSelection(selStart - str.length(), str.length()); + setSelection(selStart - str.size(), str.size()); else - setSelection(selStart, str.length()); + setSelection(selStart, str.size()); } else { - setSelection(selStart, str.length()); + setSelection(selStart, str.size()); } } } else { diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index cdfe6df7f6..e846600149 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -279,7 +279,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) if ( control->composeMode() ) { int tmp_cursor = xToPos(e->position().toPoint().x()); int mousePos = tmp_cursor - control->cursor(); - if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) + if ( mousePos < 0 || mousePos > control->preeditAreaText().size() ) mousePos = -1; if (mousePos >= 0) { diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 73ca584c7f..256e97396b 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1124,7 +1124,7 @@ QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) co QList<QDockWidget*> ret; const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); if (info && info->tabbed && info->tabBar) { - for(int i = 0; i < info->item_list.count(); ++i) { + for(int i = 0; i < info->item_list.size(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); if (item.widgetItem) { if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) { 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; diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index afa89b243b..b4d7785d94 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -750,7 +750,7 @@ void QMdiAreaPrivate::_q_currentTabChanged(int index) // If the previous active sub-window was hidden, disable the tab. if (indexToLastActiveTab >= 0 && indexToLastActiveTab < tabBar->count() - && indexToLastActiveTab < childWindows.count()) { + && indexToLastActiveTab < childWindows.size()) { QMdiSubWindow *lastActive = childWindows.at(indexToLastActiveTab); if (lastActive && lastActive->isHidden()) tabBar->setTabEnabled(indexToLastActiveTab, false); @@ -824,7 +824,7 @@ void QMdiAreaPrivate::appendChild(QMdiSubWindow *child) if (tabBar) { tabBar->addTab(child->windowIcon(), tabTextFor(child)); updateTabBarGeometry(); - if (childWindows.count() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation)) + if (childWindows.size() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation)) showActiveWindowMaximized = true; } #endif @@ -919,7 +919,7 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger) QRect domain = viewport->rect(); if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) - domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); + domain = resizeToMinimumTileSize(minSubWindowSize, widgets.size()); rearranger->rearrange(widgets, domain); @@ -1296,7 +1296,7 @@ bool QMdiAreaPrivate::scrollBarsEnabled() const */ bool QMdiAreaPrivate::lastWindowAboutToBeDestroyed() const { - if (childWindows.count() != 1) + if (childWindows.size() != 1) return false; QMdiSubWindow *last = childWindows.at(0); @@ -1372,7 +1372,7 @@ QMdiAreaPrivate::subWindowList(QMdiArea::WindowOrder order, bool reversed) const } } else { // ActivationHistoryOrder Q_ASSERT(indicesToActivatedChildren.size() == childWindows.size()); - for (int i = indicesToActivatedChildren.count() - 1; i >= 0; --i) { + for (int i = indicesToActivatedChildren.size() - 1; i >= 0; --i) { QMdiSubWindow *child = childWindows.at(indicesToActivatedChildren.at(i)); if (!child) continue; @@ -1761,7 +1761,7 @@ QMdiSubWindow *QMdiArea::currentSubWindow() const if (d->isActivated && !window()->isMinimized()) return nullptr; - Q_ASSERT(d->indicesToActivatedChildren.count() > 0); + Q_ASSERT(d->indicesToActivatedChildren.size() > 0); int index = d->indicesToActivatedChildren.at(0); Q_ASSERT(index >= 0 && index < d->childWindows.size()); QMdiSubWindow *current = d->childWindows.at(index); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index eaca88dfa7..d16a68b91b 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -110,7 +110,7 @@ public: //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*))); //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*))); QList<QAction*> items = p->actions(); - for(int i = 0; i < items.count(); i++) + for(int i = 0; i < items.size(); i++) addAction(items.at(i)); d->setMenuSize(sizeHint()); d->initialized = true; @@ -335,7 +335,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const q->ensurePolished(); //let's reinitialize the buffer - actionRects.resize(actions.count()); + actionRects.resize(actions.size()); actionRects.fill(QRect()); int lastVisibleAction = getLastVisibleAction(); @@ -360,7 +360,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const hasCheckableItems = false; ncols = 1; - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { QAction *action = actions.at(i); if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action)) continue; @@ -454,7 +454,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const int x = hmargin + fw + leftmargin; y = base_y; - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QRect &rect = actionRects[i]; if (rect.isNull()) continue; @@ -479,7 +479,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const int QMenuPrivate::getLastVisibleAction() const { //let's try to get the last visible action - int lastVisibleAction = actions.count() - 1; + int lastVisibleAction = actions.size() - 1; for (;lastVisibleAction >= 0; --lastVisibleAction) { const QAction *action = actions.at(lastVisibleAction); if (action->isVisible()) { @@ -661,7 +661,7 @@ void QMenuPrivate::setFirstActionActive() { Q_Q(QMenu); updateActionRects(); - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { const QRect &rect = actionRects.at(i); if (rect.isNull()) continue; @@ -898,7 +898,7 @@ QAction *QMenuPrivate::actionAt(QPoint p) const if (!rect().contains(p)) //sanity check return nullptr; - for(int i = 0; i < actionRects.count(); i++) { + for(int i = 0; i < actionRects.size(); i++) { if (actionRects.at(i).contains(p)) return actions.at(i); } @@ -1109,7 +1109,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); if (location == QMenuScroller::ScrollTop) { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { if (actions.at(i) == action) { newOffset = topScroll - saccum; break; @@ -1117,7 +1117,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc saccum += actionRects.at(i).height(); } } else { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { saccum += actionRects.at(i).height(); if (actions.at(i) == action) { if (location == QMenuScroller::ScrollCenter) @@ -1136,7 +1136,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc if (newOffset < 0) //easy and cheap one newScrollFlags |= QMenuScroller::ScrollUp; int saccum = newOffset; - for(int i = 0; i < actionRects.count(); i++) { + for(int i = 0; i < actionRects.size(); i++) { saccum += actionRects.at(i).height(); if (saccum > q->height()) { newScrollFlags |= QMenuScroller::ScrollDown; @@ -1193,7 +1193,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc const int delta = qMin(0, newOffset) - scroll->scrollOffset; //make sure the new offset is always negative if (!itemsDirty && delta) { //we've scrolled so we need to update the action rects - for (int i = 0; i < actionRects.count(); ++i) { + for (int i = 0; i < actionRects.size(); ++i) { QRect ¤t = actionRects[i]; current.moveTop(current.top() + delta); @@ -1260,7 +1260,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); const int offset = topScroll ? topScroll-vmargin : 0; if (direction == QMenuScroller::ScrollUp) { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { saccum -= actionRects.at(i).height(); if (saccum <= scroll->scrollOffset-offset) { scrollMenu(actions.at(i), page ? QMenuScroller::ScrollBottom : QMenuScroller::ScrollTop, active); @@ -1269,13 +1269,13 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag } } else if (direction == QMenuScroller::ScrollDown) { bool scrolled = false; - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { const int iHeight = actionRects.at(i).height(); saccum -= iHeight; if (saccum <= scroll->scrollOffset-offset) { const int scrollerArea = q->height() - botScroll - fw*2; int visible = (scroll->scrollOffset-offset) - saccum; - for(i++ ; i < actions.count(); i++) { + for(i++ ; i < actions.size(); i++) { visible += actionRects.at(i).height(); if (visible > scrollerArea - topScroll) { scrolled = true; @@ -2173,7 +2173,7 @@ QAction *QMenu::activeAction() const bool QMenu::isEmpty() const { bool ret = true; - for(int i = 0; ret && i < actions().count(); ++i) { + for(int i = 0; ret && i < actions().size(); ++i) { const QAction *action = actions().at(i); if (!action->isSeparator() && action->isVisible()) { ret = false; @@ -2238,7 +2238,7 @@ QSize QMenu::sizeHint() const d->updateActionRects(); QSize s; - for (int i = 0; i < d->actionRects.count(); ++i) { + for (int i = 0; i < d->actionRects.size(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) continue; @@ -2395,7 +2395,7 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po if (ncols > 1) { pos.setY(screen.top() + desktopFrame); } else if (atAction) { - for (int i = 0, above_height = 0; i < actions.count(); i++) { + for (int i = 0, above_height = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (action == atAction) { int newY = pos.y() - above_height; @@ -2410,7 +2410,7 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po if (scroll && scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone && !q->style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, q)) { int below_height = above_height + scroll->scrollOffset; - for (int i2 = i; i2 < actionRects.count(); i2++) + for (int i2 = i; i2 < actionRects.size(); i2++) below_height += actionRects.at(i2).height(); size.setHeight(below_height); } @@ -2744,7 +2744,7 @@ void QMenu::paintEvent(QPaintEvent *e) //draw the items that need updating.. QRect scrollUpTearOffRect = scrollUpRect.united(tearOffRect); - for (int i = 0; i < d->actions.count(); ++i) { + for (int i = 0; i < d->actions.size(); ++i) { QAction *action = d->actions.at(i); QRect actionRect = d->actionRects.at(i); if (!e->rect().intersects(actionRect) @@ -3088,7 +3088,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay; if (!d->currentAction) { if (key == Qt::Key_Down) { - for(int i = 0; i < d->actions.count(); ++i) { + for(int i = 0; i < d->actions.size(); ++i) { QAction *act = d->actions.at(i); if (d->actionRects.at(i).isNull()) continue; @@ -3100,7 +3100,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } } else { - for(int i = d->actions.count()-1; i >= 0; --i) { + for(int i = d->actions.size()-1; i >= 0; --i) { QAction *act = d->actions.at(i); if (d->actionRects.at(i).isNull()) continue; @@ -3113,7 +3113,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } } else { - for(int i = 0, y = 0; !nextAction && i < d->actions.count(); i++) { + for(int i = 0, y = 0; !nextAction && i < d->actions.size(); i++) { QAction *act = d->actions.at(i); if (act == d->currentAction) { if (key == Qt::Key_Up) { @@ -3123,7 +3123,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) break; if (d->scroll) scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; - next_i = d->actionRects.count()-1; + next_i = d->actionRects.size()-1; } QAction *next = d->actions.at(next_i); if (next == d->currentAction) @@ -3149,7 +3149,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } else { y += d->actionRects.at(i).height(); for(int next_i = i+1; true; next_i++) { - if (next_i == d->actionRects.count()) { + if (next_i == d->actionRects.size()) { if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this)) break; if (d->scroll) @@ -3306,7 +3306,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (!key_consumed) { // send to menu bar if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) && - e->text().length()==1) { + e->text().size()==1) { bool activateAction = false; QAction *nextAction = nullptr; if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, nullptr, this) && !e->modifiers()) { diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 15c6f521b3..01ad37cab0 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -168,7 +168,7 @@ void QMenuBarPrivate::updateGeometries() for(int j = 0; j < shortcutIndexMap.size(); ++j) q->releaseShortcut(shortcutIndexMap.value(j)); shortcutIndexMap.clear(); - const int actionsCount = actions.count(); + const int actionsCount = actions.size(); shortcutIndexMap.reserve(actionsCount); for (int i = 0; i < actionsCount; i++) shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); @@ -182,7 +182,7 @@ void QMenuBarPrivate::updateGeometries() //we try to see if the actions will fit there bool hasHiddenActions = false; - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { const QRect &rect = actionRects.at(i); if (rect.isValid() && !menuRect.contains(rect)) { hasHiddenActions = true; @@ -193,7 +193,7 @@ void QMenuBarPrivate::updateGeometries() //...and if not, determine the ones that fit on the menu with the extension visible if (hasHiddenActions) { menuRect = this->menuRect(true); - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { const QRect &rect = actionRects.at(i); if (rect.isValid() && !menuRect.contains(rect)) { hiddenActions.append(actions.at(i)); @@ -201,7 +201,7 @@ void QMenuBarPrivate::updateGeometries() } } - if (hiddenActions.count() > 0) { + if (hiddenActions.size() > 0) { QMenu *pop = extension->menu(); if (!pop) { pop = new QMenu(q); @@ -229,7 +229,7 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const //makes sure the geometries are up-to-date const_cast<QMenuBarPrivate*>(this)->updateGeometries(); - if (index < 0 || index >= actionRects.count()) + if (index < 0 || index >= actionRects.size()) return QRect(); // that can happen in case of native menubar return actionRects.at(index); @@ -240,8 +240,8 @@ void QMenuBarPrivate::focusFirstAction() if (!currentAction) { updateGeometries(); int index = 0; - while (index < actions.count() && actionRects.at(index).isNull()) ++index; - if (index < actions.count()) + while (index < actions.size() && actionRects.at(index).isNull()) ++index; + if (index < actions.size()) setCurrentAction(actions.at(index)); } } @@ -378,7 +378,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const return; //let's reinitialize the buffer - actionRects.resize(actions.count()); + actionRects.resize(actions.size()); actionRects.fill(QRect()); const QStyle *style = q->style(); @@ -391,7 +391,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q), vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q), icone = style->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q); - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (!action->isVisible()) continue; @@ -437,7 +437,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); int x = fw + ((start == -1) ? hmargin : start) + itemSpacing; int y = fw + vmargin; - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QRect &rect = actionRects[i]; if (rect.isNull()) continue; @@ -680,8 +680,8 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c Q_Q(const QMenuBar); const_cast<QMenuBarPrivate*>(this)->updateGeometries(); bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q); - const int start = (_start == -1 && increment == -1) ? actions.count() : _start; - const int end = increment == -1 ? 0 : actions.count() - 1; + const int start = (_start == -1 && increment == -1) ? actions.size() : _start; + const int end = increment == -1 ? 0 : actions.size() - 1; for (int i = start; i != end;) { i += increment; @@ -884,7 +884,7 @@ void QMenuBar::paintEvent(QPaintEvent *e) QRegion emptyArea(rect()); //draw the items - for (int i = 0; i < d->actions.count(); ++i) { + for (int i = 0; i < d->actions.size(); ++i) { QAction *action = d->actions.at(i); QRect adjustedActionRect = d->actionRect(action); if (adjustedActionRect.isEmpty() || !d->isVisible(action)) @@ -1060,7 +1060,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) if (!key_consumed && (!e->modifiers() || - (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) { + (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().size()==1 && !d->popupState) { int clashCount = 0; QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr; { @@ -1525,7 +1525,7 @@ QSize QMenuBar::minimumSizeHint() const if (as_gui_menubar) { int w = parentWidget() ? parentWidget()->width() : QGuiApplication::primaryScreen()->virtualGeometry().width(); d->calcActionRects(w - (2 * fw), 0); - for (int i = 0; ret.isNull() && i < d->actions.count(); ++i) + for (int i = 0; ret.isNull() && i < d->actions.size(); ++i) ret = d->actionRects.at(i).size(); if (!d->extension->isHidden()) ret += QSize(d->extension->sizeHint().width(), 0); @@ -1575,7 +1575,7 @@ QSize QMenuBar::sizeHint() const if (as_gui_menubar) { const int w = parentWidget() ? parentWidget()->width() : QGuiApplication::primaryScreen()->virtualGeometry().width(); d->calcActionRects(w - (2 * fw), 0); - for (int i = 0; i < d->actionRects.count(); ++i) { + for (int i = 0; i < d->actionRects.size(); ++i) { const QRect &actionRect = d->actionRects.at(i); ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height())); } @@ -1622,7 +1622,7 @@ int QMenuBar::heightForWidth(int) const int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this); if (as_gui_menubar) { - for (int i = 0; i < d->actionRects.count(); ++i) + for (int i = 0; i < d->actionRects.size(); ++i) height = qMax(height, d->actionRects.at(i).height()); if (height) //there is at least one non-null item height += spaceBelowMenuBar; diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index a954d6ce66..84c3799494 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -361,7 +361,7 @@ void QSplitterPrivate::init() void QSplitterPrivate::recalc(bool update) { Q_Q(QSplitter); - int n = list.count(); + int n = list.size(); /* Splitter handles before the first visible widget or right before a hidden widget must be hidden. @@ -451,7 +451,7 @@ void QSplitterPrivate::doResize() { Q_Q(QSplitter); QRect r = q->contentsRect(); - int n = list.count(); + int n = list.size(); QList<QLayoutStruct> a(n * 2); int i; @@ -565,7 +565,7 @@ int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int return index; } index += delta; - } while (index >= 0 && index < list.count()); + } while (index >= 0 && index < list.size()); return -1; } @@ -577,7 +577,7 @@ int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int void QSplitterPrivate::getRange(int index, int *farMin, int *min, int *max, int *farMax) const { Q_Q(const QSplitter); - int n = list.count(); + int n = list.size(); if (index <= 0 || index >= n) return; @@ -757,7 +757,7 @@ void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool all void QSplitterPrivate::doMove(bool backwards, int hPos, int index, int delta, bool mayCollapse, int *positions, int *widths) { - if (index < 0 || index >= list.count()) + if (index < 0 || index >= list.size()) return; #ifdef QSPLITTER_DEBUG @@ -827,7 +827,7 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) Q_Q(QSplitter); QSplitterLayoutStruct *sls = nullptr; int i; - int last = list.count(); + int last = list.size(); for (i = 0; i < list.size(); ++i) { QSplitterLayoutStruct *s = list.at(i); if (s->widget == w) { @@ -1079,7 +1079,7 @@ void QSplitter::resizeEvent(QResizeEvent *) void QSplitter::addWidget(QWidget *widget) { Q_D(QSplitter); - insertWidget(d->list.count(), widget); + insertWidget(d->list.size(), widget); } /*! @@ -1129,7 +1129,7 @@ QWidget *QSplitter::replaceWidget(int index, QWidget *widget) return nullptr; } - if (index < 0 || index >= d->list.count()) { + if (index < 0 || index >= d->list.size()) { qWarning("QSplitter::replaceWidget: Index %d out of range", index); return nullptr; } @@ -1242,7 +1242,7 @@ QWidget *QSplitter::widget(int index) const int QSplitter::count() const { Q_D(const QSplitter); - return d->list.count(); + return d->list.size(); } /*! @@ -1271,7 +1271,7 @@ void QSplitter::childEvent(QChildEvent *c) } QWidget *w = static_cast<QWidget*>(c->child()); if (!d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) - d->insertWidget_helper(d->list.count(), w, false); + d->insertWidget_helper(d->list.size(), w, false); } else if (c->polished()) { if (!c->child()->isWidgetType()) return; @@ -1398,15 +1398,15 @@ void QSplitter::moveSplitter(int pos, int index) qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; #endif - QVarLengthArray<int, 32> poss(d->list.count()); - QVarLengthArray<int, 32> ws(d->list.count()); + QVarLengthArray<int, 32> poss(d->list.size()); + QVarLengthArray<int, 32> ws(d->list.size()); bool upLeft; d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data()); upLeft = (pos < oldP); - int wid, delta, count = d->list.count(); + int wid, delta, count = d->list.size(); if (upLeft) { wid = 0; delta = 1; @@ -1751,7 +1751,7 @@ bool QSplitter::restoreState(const QByteArray &state) void QSplitter::setStretchFactor(int index, int stretch) { Q_D(QSplitter); - if (index <= -1 || index >= d->list.count()) + if (index <= -1 || index >= d->list.size()) return; QWidget *widget = d->list.at(index)->widget; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 29b568f29d..ad6d28c523 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -404,7 +404,7 @@ int QTabBarPrivate::indexAtPos(const QPoint &p) const Q_Q(const QTabBar); if (q->tabRect(currentIndex).contains(p)) return currentIndex; - for (int i = 0; i < tabList.count(); ++i) + for (int i = 0; i < tabList.size(); ++i) if (tabList.at(i)->enabled && q->tabRect(i).contains(p)) return i; return -1; @@ -422,7 +422,7 @@ void QTabBarPrivate::layoutTabs() int hiddenTabs = 0; Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, nullptr, q)); - QList<QLayoutStruct> tabChain(tabList.count() + 2); + QList<QLayoutStruct> tabChain(tabList.size() + 2); // We put an empty item at the front and back and set its expansive attribute // depending on tabAlignment and expanding. @@ -445,7 +445,7 @@ void QTabBarPrivate::layoutTabs() int minx = 0; int x = 0; int maxHeight = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { const auto tab = tabList.at(i); if (!tab->visible) { ++hiddenTabs; @@ -476,7 +476,7 @@ void QTabBarPrivate::layoutTabs() int miny = 0; int y = 0; int maxWidth = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { auto tab = tabList.at(i); if (!tab->visible) { ++hiddenTabs; @@ -511,14 +511,14 @@ void QTabBarPrivate::layoutTabs() && (tabAlignment != Qt::AlignRight) && (tabAlignment != Qt::AlignJustify); tabChain[tabChainIndex].empty = true; - Q_ASSERT(tabChainIndex == tabChain.count() - 1 - hiddenTabs); // add an assert just to make sure. + Q_ASSERT(tabChainIndex == tabChain.size() - 1 - hiddenTabs); // add an assert just to make sure. // Do the calculation - qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0); + qGeomCalc(tabChain, 0, tabChain.size(), 0, qMax(available, last), 0); // Use the results hiddenTabs = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { auto tab = tabList.at(i); if (!tab->visible) { tab->rect = QRect(); @@ -532,7 +532,7 @@ void QTabBarPrivate::layoutTabs() tab->rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); } - if (useScrollButtons && tabList.count() && last > available) { + if (useScrollButtons && tabList.size() && last > available) { const QRect scrollRect = normalizedScrollRect(0); scrollOffset = -scrollRect.left(); @@ -768,7 +768,7 @@ void QTabBarPrivate::_q_closeTab() QObject *object = q->sender(); int tabToClose = -1; QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, q); - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { if (closeSide == QTabBar::LeftSide) { if (tabList.at(i)->leftWidget == object) { tabToClose = i; @@ -795,7 +795,7 @@ void QTabBarPrivate::_q_scrollTabs() int i = -1; if (sender == leftB) { - for (i = tabList.count() - 1; i >= 0; --i) { + for (i = tabList.size() - 1; i >= 0; --i) { int start = horizontal ? tabList.at(i)->rect.left() : tabList.at(i)->rect.top(); if (start < scrollRect.left()) { makeVisible(i); @@ -803,7 +803,7 @@ void QTabBarPrivate::_q_scrollTabs() } } } else if (sender == rightB) { - for (i = 0; i < tabList.count(); ++i) { + for (i = 0; i < tabList.size(); ++i) { const auto tabRect = tabList.at(i)->rect; int start = horizontal ? tabRect.left() : tabRect.top(); int end = horizontal ? tabRect.right() : tabRect.bottom(); @@ -950,7 +950,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) { Q_D(QTabBar); if (!d->validIndex(index)) { - index = d->tabList.count(); + index = d->tabList.size(); d->tabList.append(new QTabBarPrivate::Tab(icon, text)); } else { d->tabList.insert(index, new QTabBarPrivate::Tab(icon, text)); @@ -960,7 +960,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) #endif d->firstVisible = qMax(qMin(index, d->firstVisible), 0); d->refresh(); - if (d->tabList.count() == 1) + if (d->tabList.size() == 1) setCurrentIndex(index); else if (index <= d->currentIndex) ++d->currentIndex; @@ -1469,7 +1469,7 @@ void QTabBar::setIconSize(const QSize &size) int QTabBar::count() const { Q_D(const QTabBar); - return d->tabList.count(); + return d->tabList.size(); } @@ -1512,7 +1512,7 @@ QSize QTabBar::minimumSizeHint() const // Compute the most-elided possible text, for minimumSizeHint static QString computeElidedText(Qt::TextElideMode mode, const QString &text) { - if (text.length() <= 3) + if (text.size() <= 3) return text; static const auto Ellipses = "..."_L1; @@ -1721,7 +1721,7 @@ bool QTabBar::event(QEvent *event) case QEvent::Shortcut: { QShortcutEvent *se = static_cast<QShortcutEvent *>(event); - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { const QTabBarPrivate::Tab *tab = d->tabList.at(i); if (tab->shortcutId == se->shortcutId()) { setCurrentIndex(i); @@ -1804,7 +1804,7 @@ void QTabBar::paintEvent(QPaintEvent *) selected = d->pressedIndex; const QRect scrollRect = d->normalizedScrollRect(); - for (int i = 0; i < d->tabList.count(); ++i) + for (int i = 0; i < d->tabList.size(); ++i) optTabBase.tabBarRect |= tabRect(i); optTabBase.selectedTabRect = tabRect(selected); @@ -1826,7 +1826,7 @@ void QTabBar::paintEvent(QPaintEvent *) p.setClipRegion(QRegion(rect()) - buttonRegion); } - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { const auto tab = d->tabList.at(i); if (!tab->visible) continue; @@ -1916,7 +1916,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem } else { if (remove || (index == firstVisible)) { firstVisible = -1; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { if (tabList.at(i)->visible) { firstVisible = i; break; @@ -1925,7 +1925,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem } if (remove || (index == lastVisible)) { lastVisible = -1; - for (int i = tabList.count() - 1; i >= 0; --i) { + for (int i = tabList.size() - 1; i >= 0; --i) { if (tabList.at(i)->visible) { lastVisible = i; break; @@ -1943,7 +1943,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem int QTabBarPrivate::selectNewCurrentIndexFrom(int fromIndex) { int newindex = -1; - for (int i = fromIndex; i < tabList.count(); ++i) { + for (int i = fromIndex; i < tabList.size(); ++i) { if (at(i)->visible && at(i)->enabled) { newindex = i; break; @@ -2557,7 +2557,7 @@ void QTabBar::setTabsClosable(bool closable) } } else { bool newButtons = false; - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { if (tabButton(i, closeSide)) continue; newButtons = true; @@ -2766,7 +2766,7 @@ void QTabBar::setChangeCurrentOnDrag(bool change) void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget) { Q_D(QTabBar); - if (index < 0 || index >= d->tabList.count()) + if (index < 0 || index >= d->tabList.size()) return; if (widget) { widget->setParent(this); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index e38b1ef6f9..a421836b93 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -184,7 +184,7 @@ public: int indexAtPos(const QPoint &p) const; inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0; } - inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } + inline bool validIndex(int index) const { return index >= 0 && index < tabList.size(); } void setCurrentNextEnabledIndex(int offset); void _q_scrollTabs(); diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 2bab2efc61..63edfc5328 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -64,13 +64,13 @@ public: HistoryEntry history(int i) const { if (i <= 0) - if (-i < stack.count()) - return stack[stack.count()+i-1]; + if (-i < stack.size()) + return stack[stack.size()+i-1]; else return HistoryEntry(); else - if (i <= forwardStack.count()) - return forwardStack[forwardStack.count()-i]; + if (i <= forwardStack.size()) + return forwardStack[forwardStack.size()-i]; else return HistoryEntry(); } @@ -828,11 +828,11 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type entry.vpos = 0; d->stack.push(entry); - emit backwardAvailable(d->stack.count() > 1); + emit backwardAvailable(d->stack.size() > 1); if (!d->forwardStack.isEmpty() && d->forwardStack.top().url == url) { d->forwardStack.pop(); - emit forwardAvailable(d->forwardStack.count() > 0); + emit forwardAvailable(d->forwardStack.size() > 0); } else { d->forwardStack.clear(); emit forwardAvailable(false); @@ -906,14 +906,14 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type void QTextBrowser::backward() { Q_D(QTextBrowser); - if (d->stack.count() <= 1) + if (d->stack.size() <= 1) return; // Update the history entry d->forwardStack.push(d->createHistoryEntry()); d->stack.pop(); // throw away the old version of the current entry d->restoreHistoryEntry(d->stack.top()); // previous entry - emit backwardAvailable(d->stack.count() > 1); + emit backwardAvailable(d->stack.size() > 1); emit forwardAvailable(true); emit historyChanged(); } @@ -1156,7 +1156,7 @@ QVariant QTextBrowser::loadResource(int /*type*/, const QUrl &name) bool QTextBrowser::isBackwardAvailable() const { Q_D(const QTextBrowser); - return d->stack.count() > 1; + return d->stack.size() > 1; } /*! @@ -1243,7 +1243,7 @@ QString QTextBrowser::historyTitle(int i) const int QTextBrowser::forwardHistoryCount() const { Q_D(const QTextBrowser); - return d->forwardStack.count(); + return d->forwardStack.size(); } /*! @@ -1254,7 +1254,7 @@ int QTextBrowser::forwardHistoryCount() const int QTextBrowser::backwardHistoryCount() const { Q_D(const QTextBrowser); - return d->stack.count()-1; + return d->stack.size()-1; } /*! diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index b3a8963431..f3d1d3e511 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1371,7 +1371,7 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) const QString text = e->text(); if (cursor.atBlockStart() && (d->autoFormatting & AutoBulletList) - && (text.length() == 1) + && (text.size() == 1) && (text.at(0) == u'-' || text.at(0) == u'*') && (!cursor.currentList())) { diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 6334874a4c..54c21b6038 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -70,7 +70,7 @@ QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation) QSize QToolBarAreaLayoutLine::sizeHint() const { int a = 0, b = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { const QToolBarAreaLayoutItem &item = toolBarItems.at(i); if (item.skip()) continue; @@ -90,7 +90,7 @@ QSize QToolBarAreaLayoutLine::sizeHint() const QSize QToolBarAreaLayoutLine::minimumSize() const { int a = 0, b = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { const QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -114,7 +114,7 @@ void QToolBarAreaLayoutLine::fitLayout() int space = pick(o, rect.size()); int extra = qMax(0, space - min); - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -137,7 +137,7 @@ void QToolBarAreaLayoutLine::fitLayout() // calculate the positions from the sizes int pos = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -151,7 +151,7 @@ void QToolBarAreaLayoutLine::fitLayout() bool QToolBarAreaLayoutLine::skip() const { - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { if (!toolBarItems.at(i).skip()) return false; } @@ -183,7 +183,7 @@ QToolBarAreaLayoutInfo::QToolBarAreaLayoutInfo(QInternal::DockPosition pos) QSize QToolBarAreaLayoutInfo::sizeHint() const { int a = 0, b = 0; - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { const QToolBarAreaLayoutLine &l = lines.at(i); if (l.skip()) continue; @@ -203,7 +203,7 @@ QSize QToolBarAreaLayoutInfo::sizeHint() const QSize QToolBarAreaLayoutInfo::minimumSize() const { int a = 0, b = 0; - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { const QToolBarAreaLayoutLine &l = lines.at(i); if (l.skip()) continue; @@ -228,9 +228,9 @@ void QToolBarAreaLayoutInfo::fitLayout() bool reverse = dockPos == QInternal::RightDock || dockPos == QInternal::BottomDock; - int i = reverse ? lines.count() - 1 : 0; + int i = reverse ? lines.size() - 1 : 0; for (;;) { - if ((reverse && i < 0) || (!reverse && i == lines.count())) + if ((reverse && i < 0) || (!reverse && i == lines.size())) break; QToolBarAreaLayoutLine &l = lines[i]; @@ -273,10 +273,10 @@ void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) return; } - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { line.toolBarItems.insert(k, item); return; @@ -287,17 +287,17 @@ void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar) { - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (item.widgetItem->widget() == toolBar) { delete item.widgetItem; item.widgetItem = nullptr; line.toolBarItems.removeAt(k); - if (line.toolBarItems.isEmpty() && j < lines.count() - 1) + if (line.toolBarItems.isEmpty() && j < lines.size() - 1) lines.removeAt(j); return; @@ -315,10 +315,10 @@ void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) return; } - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { if (k == 0) return; @@ -336,10 +336,10 @@ void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) void QToolBarAreaLayoutInfo::removeToolBarBreak(QToolBar *before) { - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { const QToolBarAreaLayoutLine &line = lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { if (k != 0) return; @@ -366,12 +366,12 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) pos -= rect.top(); //here we actually update the preferredSize for the line containing the toolbar so that we move it - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; int previousIndex = -1; int minPos = 0; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem ¤t = line.toolBarItems[k]; if (current.widgetItem->widget() == toolbar) { int newPos = current.pos; @@ -383,7 +383,7 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) } else { //we check the max value for the position (until everything at the right is "compressed") int maxPos = pick(o, rect.size()); - for(int l = k; l < line.toolBarItems.count(); ++l) { + for(int l = k; l < line.toolBarItems.size(); ++l) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(l); if (!item.skip()) { maxPos -= pick(o, item.minimumSize()); @@ -451,7 +451,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) // Since we're comparing p with item.pos, we put them in the same coordinate system. const int p = pick(o, pos - rect.topLeft()); - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { const QToolBarAreaLayoutLine &line = lines.at(j); if (line.skip()) continue; @@ -459,7 +459,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) continue; int k = 0; - for (; k < line.toolBarItems.count(); ++k) { + for (; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (item.skip()) continue; @@ -485,7 +485,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) *minDistance = dist; QList<int> result; - result << lines.count() << 0; + result << lines.size() << 0; return result; } } @@ -495,9 +495,9 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(path.count() == 2); + Q_ASSERT(path.size() == 2); int j = path.first(); - if (j == lines.count()) + if (j == lines.size()) lines.append(QToolBarAreaLayoutLine(o)); QToolBarAreaLayoutLine &line = lines[j]; @@ -540,7 +540,7 @@ void QToolBarAreaLayoutInfo::clear() QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const { - Q_ASSERT(path.count() == 2); + Q_ASSERT(path.size() == 2); int j = path.at(0); int k = path.at(1); @@ -698,10 +698,10 @@ QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if ((*x)++ == index) return line.toolBarItems.at(k).widgetItem; } @@ -718,10 +718,10 @@ QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index) for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if ((*x)++ == index) { QLayoutItem *result = line.toolBarItems.takeAt(k).widgetItem; if (line.toolBarItems.isEmpty()) @@ -740,10 +740,10 @@ void QToolBarAreaLayout::deleteAllLayoutItems() for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (!item.gap) delete item.widgetItem; @@ -758,10 +758,10 @@ QInternal::DockPosition QToolBarAreaLayout::findToolBar(const QToolBar *toolBar) for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) return static_cast<QInternal::DockPosition>(i); } @@ -849,12 +849,12 @@ void QToolBarAreaLayout::apply(bool animate) for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); if (line.skip()) continue; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (item.skip() || item.gap) continue; @@ -907,10 +907,10 @@ bool QToolBarAreaLayout::toolBarBreak(QToolBar *toolBar) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) return j > 0 && k == 0; } @@ -925,25 +925,25 @@ void QToolBarAreaLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBa for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) { - if (line.toolBarItems.count() == 1) + if (line.toolBarItems.size() == 1) option->positionWithinLine = QStyleOptionToolBar::OnlyOne; else if (k == 0) option->positionWithinLine = QStyleOptionToolBar::Beginning; - else if (k == line.toolBarItems.count() - 1) + else if (k == line.toolBarItems.size() - 1) option->positionWithinLine = QStyleOptionToolBar::End; else option->positionWithinLine = QStyleOptionToolBar::Middle; - if (dock.lines.count() == 1) + if (dock.lines.size() == 1) option->positionOfLine = QStyleOptionToolBar::OnlyOne; else if (j == 0) option->positionOfLine = QStyleOptionToolBar::Beginning; - else if (j == dock.lines.count() - 1) + else if (j == dock.lines.size() - 1) option->positionOfLine = QStyleOptionToolBar::End; else option->positionOfLine = QStyleOptionToolBar::Middle; @@ -964,10 +964,10 @@ QList<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (!item.gap && item.widgetItem->widget() == toolBar) { found = true; @@ -1016,10 +1016,10 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); k++) { + for (int k = 0; k < line.toolBarItems.size(); k++) { if (line.toolBarItems[k].gap) { QList<int> result; result << i << j << k; @@ -1033,7 +1033,7 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); const int i = path.first(); Q_ASSERT(i >= 0 && i < QInternal::DockCount); return docks[i].insertGap(path.mid(1), item); @@ -1041,7 +1041,7 @@ bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) void QToolBarAreaLayout::remove(const QList<int> &path) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); QToolBarAreaLayoutInfo &dock = docks[path.at(0)]; QToolBarAreaLayoutLine &line = dock.lines[path.at(1)]; line.toolBarItems.removeAt(path.at(2)); @@ -1054,10 +1054,10 @@ void QToolBarAreaLayout::remove(QLayoutItem *item) for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); k++) { + for (int k = 0; k < line.toolBarItems.size(); k++) { if (line.toolBarItems[k].widgetItem == item) { line.toolBarItems.removeAt(k); if (line.toolBarItems.isEmpty()) @@ -1078,15 +1078,15 @@ void QToolBarAreaLayout::clear() QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount) return nullptr; QToolBarAreaLayoutInfo &info = docks[path.at(0)]; - if (path.at(1) < 0 || path.at(1) >= info.lines.count()) + if (path.at(1) < 0 || path.at(1) >= info.lines.size()) return nullptr; QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; - if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count()) + if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.size()) return nullptr; return &(line.toolBarItems[path.at(2)]); } @@ -1118,7 +1118,7 @@ QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other) { //other needs to be update as well - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); QToolBarAreaLayoutItem *item = this->item(path); Q_ASSERT(item); @@ -1136,7 +1136,7 @@ QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayo if (!previous.skip()) { //we need to check if it has a previous element and a next one //the previous will get its size changed - for (int j = path.at(2) + 1; j < line.toolBarItems.count(); ++j) { + for (int j = path.at(2) + 1; j < line.toolBarItems.size(); ++j) { const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j); if (!next.skip()) { newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint()); @@ -1221,19 +1221,19 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const int lineCount = 0; for (int i = 0; i < QInternal::DockCount; ++i) - lineCount += docks[i].lines.count(); + lineCount += docks[i].lines.size(); stream << lineCount; for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - stream << i << int(line.toolBarItems.count()); + stream << i << int(line.toolBarItems.size()); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); QWidget *widget = const_cast<QLayoutItem*>(item.widgetItem)->widget(); QString objectName = widget->objectName(); @@ -1317,7 +1317,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar* } QToolBar *toolBar = nullptr; - for (int x = 0; x < toolBars.count(); ++x) { + for (int x = 0; x < toolBars.size(); ++x) { if (toolBars.at(x)->objectName() == objectName) { toolBar = toolBars.takeAt(x); break; diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index ebfece96d0..cc842e2657 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -132,14 +132,14 @@ void QToolBarLayout::addItem(QLayoutItem*) QLayoutItem *QToolBarLayout::itemAt(int index) const { - if (index < 0 || index >= items.count()) + if (index < 0 || index >= items.size()) return nullptr; return items.at(index); } QLayoutItem *QToolBarLayout::takeAt(int index) { - if (index < 0 || index >= items.count()) + if (index < 0 || index >= items.size()) return nullptr; QToolBarItem *item = items.takeAt(index); @@ -162,7 +162,7 @@ QLayoutItem *QToolBarLayout::takeAt(int index) void QToolBarLayout::insertAction(int index, QAction *action) { index = qMax(0, index); - index = qMin(items.count(), index); + index = qMin(items.size(), index); QToolBarItem *item = createItem(action); if (item) { @@ -173,7 +173,7 @@ void QToolBarLayout::insertAction(int index, QAction *action) int QToolBarLayout::indexOf(const QAction *action) const { - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { if (items.at(i)->action == action) return i; } @@ -182,7 +182,7 @@ int QToolBarLayout::indexOf(const QAction *action) const int QToolBarLayout::count() const { - return items.count(); + return items.size(); } bool QToolBarLayout::isEmpty() const @@ -246,10 +246,10 @@ void QToolBarLayout::updateGeomArray() const that->expanding = false; that->empty = false; - QList<QLayoutStruct> a(items.count() + 1); // + 1 for the stretch + QList<QLayoutStruct> a(items.size() + 1); // + 1 for the stretch int count = 0; - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { QToolBarItem *item = items.at(i); QSize max = item->maximumSize(); @@ -296,7 +296,7 @@ void QToolBarLayout::updateGeomArray() const rpick(o, that->minSize) += handleExtent; that->minSize += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins)); - if (items.count() > 1) + if (items.size() > 1) rpick(o, that->minSize) += spacing + extensionExtent; rpick(o, that->hint) += handleExtent; @@ -431,7 +431,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) int rows = 0; int rowPos = perp(o, rect.topLeft()) + perp(o, QSize(margins.top(), margins.left())); int i = 0; - while (i < items.count()) { + while (i < items.size()) { QList<QLayoutStruct> a = geomArray; int start = i; @@ -441,7 +441,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) int count = 0; int maximumSize = 0; bool expansiveRow = false; - for (; i < items.count(); ++i) { + for (; i < items.size(); ++i) { if (a[i].empty) continue; @@ -512,7 +512,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) } if (!expanded) { - for (int j = i; j < items.count(); ++j) { + for (int j = i; j < items.size(); ++j) { QToolBarItem *item = items.at(j); if (!item->widget()->isHidden()) hideWidgets << item->widget(); @@ -537,9 +537,9 @@ bool QToolBarLayout::layoutActions(const QSize &size) extension->setEnabled(popupMenu == nullptr || !extensionMenuContainsOnlyWidgetActions); // we have to do the show/hide here, because it triggers more calls to setGeometry :( - for (int i = 0; i < showWidgets.count(); ++i) + for (int i = 0; i < showWidgets.size(); ++i) showWidgets.at(i)->show(); - for (int i = 0; i < hideWidgets.count(); ++i) + for (int i = 0; i < hideWidgets.size(); ++i) hideWidgets.at(i)->hide(); return ranOutOfSpace; @@ -566,7 +566,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const int total_w = 0; int count = 0; - for (int x = 0; x < items.count(); ++x) { + for (int x = 0; x < items.size(); ++x) { if (!geomArray[x].empty) { total_w += (count == 0 ? 0 : spacing) + geomArray[x].minimumSize; ++count; @@ -587,12 +587,12 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const int w = 0; int h = 0; int i = 0; - while (i < items.count()) { + while (i < items.size()) { int count = 0; int size = 0; int prev = -1; int rowHeight = 0; - for (; i < items.count(); ++i) { + for (; i < items.size(); ++i) { if (geomArray[i].empty) continue; diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index e95509ae89..30465b95fa 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -62,7 +62,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) if (m_echoMode == QLineEdit::Password) { str.fill(m_passwordCharacter); - if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { + if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.size()) { int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); str[cursor] = uc; @@ -82,7 +82,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) // drawing boxes when using fonts that don't have glyphs for such // characters) QChar* uc = str.data(); - for (int i = 0; i < (int)str.length(); ++i) { + for (int i = 0; i < (int)str.size(); ++i) { if ((uc[i].unicode() < 0x20 && uc[i].unicode() != 0x09) || uc[i] == QChar::LineSeparator || uc[i] == QChar::ParagraphSeparator @@ -242,7 +242,7 @@ void QWidgetLineControl::clear() { int priorState = m_undoState; m_selstart = 0; - m_selend = m_text.length(); + m_selend = m_text.size(); removeSelectedText(); separate(); finishChange(priorState, /*update*/false, /*edited*/false); @@ -286,7 +286,7 @@ void QWidgetLineControl::setSelection(int start, int length) if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) return; m_selstart = start; - m_selend = qMin(start + length, (int)m_text.length()); + m_selend = qMin(start + length, (int)m_text.size()); m_cursor = m_selend; } else if (length < 0){ if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) @@ -329,7 +329,7 @@ void QWidgetLineControl::init(const QString &txt) m_textLayout.setCacheEnabled(true); m_text = txt; updateDisplayText(); - m_cursor = m_text.length(); + m_cursor = m_text.size(); if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); m_passwordMaskDelay = theme->themeHint(QPlatformTheme::PasswordMaskDelay).toInt(); @@ -491,14 +491,14 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing()) { updatePasswordEchoEditing(true); m_selstart = 0; - m_selend = m_text.length(); + m_selend = m_text.size(); } removeSelectedText(); } int c = m_cursor; // cursor position after insertion of commit string if (event->replacementStart() <= 0) - c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); + c += event->commitString().size() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); if (m_cursor < 0) @@ -514,15 +514,15 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) internalInsert(event->commitString()); cursorPositionChanged = true; } else { - m_cursor = qBound(0, c, m_text.length()); + m_cursor = qBound(0, c, m_text.size()); } for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); if (a.type == QInputMethodEvent::Selection) { - m_cursor = qBound(0, a.start + a.length, m_text.length()); + m_cursor = qBound(0, a.start + a.length, m_text.size()); if (a.length) { - m_selstart = qMax(0, qMin(a.start, m_text.length())); + m_selstart = qMax(0, qMin(a.start, m_text.size())); m_selend = m_cursor; if (m_selend < m_selstart) { qSwap(m_selstart, m_selend); @@ -554,7 +554,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) } #endif //QT_NO_IM const int oldPreeditCursor = m_preeditCursor; - m_preeditCursor = event->preeditString().length(); + m_preeditCursor = event->preeditString().size(); m_hideCursor = false; QList<QTextLayout::FormatRange> formats; formats.reserve(event->attributes().size()); @@ -695,7 +695,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e } #endif if (validateFromState >= 0 && wasValidInput && !m_validInput) { - if (m_transactions.count()) + if (m_transactions.size()) return false; internalUndo(validateFromState); m_history.erase(m_history.begin() + m_undoState, m_history.end()); @@ -737,7 +737,7 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite QString oldText = m_text; if (m_maskData) { m_text = maskString(0, txt, true); - m_text += clearString(m_text.length(), m_maxLength - m_text.length()); + m_text += clearString(m_text.size(), m_maxLength - m_text.size()); if (edited && oldText == m_text) emit inputRejected(); } else { @@ -745,7 +745,7 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite } m_history.clear(); m_modifiedState = m_undoState = 0; - m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; + m_cursor = (pos < 0 || pos > m_text.size()) ? m_text.size() : pos; m_textDirty = (oldText != m_text); const bool changed = finishChange(-1, true, edited); @@ -823,12 +823,12 @@ void QWidgetLineControl::internalInsert(const QString &s) QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, ms); QAccessible::updateAccessibility(&insertEvent); #endif - for (int i = 0; i < (int) ms.length(); ++i) { + for (int i = 0; i < (int) ms.size(); ++i) { addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); } - m_text.replace(m_cursor, ms.length(), ms); - m_cursor += ms.length(); + m_text.replace(m_cursor, ms.size(), ms); + m_cursor += ms.size(); m_cursor = nextMaskBlank(m_cursor); m_textDirty = true; #if QT_CONFIG(accessibility) @@ -836,18 +836,18 @@ void QWidgetLineControl::internalInsert(const QString &s) QAccessible::updateAccessibility(&event); #endif } else { - int remaining = m_maxLength - m_text.length(); + int remaining = m_maxLength - m_text.size(); if (remaining != 0) { #if QT_CONFIG(accessibility) QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, s); QAccessible::updateAccessibility(&insertEvent); #endif m_text.insert(m_cursor, s.left(remaining)); - for (int i = 0; i < (int) s.left(remaining).length(); ++i) + for (int i = 0; i < (int) s.left(remaining).size(); ++i) addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); m_textDirty = true; } - if (s.length() > remaining) + if (s.size() > remaining) emit inputRejected(); } } @@ -865,7 +865,7 @@ void QWidgetLineControl::internalInsert(const QString &s) */ void QWidgetLineControl::internalDelete(bool wasBackspace) { - if (m_cursor < (int) m_text.length()) { + if (m_cursor < (int) m_text.size()) { cancelPasswordEchoTimer(); if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, u'\0', m_selstart, m_selend)); @@ -896,7 +896,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace) */ void QWidgetLineControl::removeSelectedText() { - if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { + if (m_selstart < m_selend && m_selend <= (int) m_text.size()) { cancelPasswordEchoTimer(); separate(); int i ; @@ -953,13 +953,13 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) m_inputMask = maskFields; } else { m_inputMask = maskFields.left(delimiter); - m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : u' '; + m_blank = (delimiter + 1 < maskFields.size()) ? maskFields[delimiter + 1] : u' '; } // calculate m_maxLength / m_maskData length m_maxLength = 0; bool escaped = false; - for (int i=0; i<m_inputMask.length(); i++) { + for (int i=0; i<m_inputMask.size(); i++) { const auto c = m_inputMask.at(i); if (escaped) { ++m_maxLength; @@ -983,7 +983,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) bool s; bool escape = false; int index = 0; - for (int i = 0; i < m_inputMask.length(); i++) { + for (int i = 0; i < m_inputMask.size(); i++) { const auto c = m_inputMask.at(i); if (escape) { s = true; @@ -1132,7 +1132,7 @@ bool QWidgetLineControl::hasAcceptableInput(const QString &str) const if (!m_maskData) return true; - if (str.length() != m_maxLength) + if (str.size() != m_maxLength) return false; for (int i=0; i < m_maxLength; ++i) { @@ -1167,7 +1167,7 @@ QString QWidgetLineControl::maskString(int pos, const QString &str, bool clear) QString s = QString::fromLatin1(""); int i = pos; while (i < m_maxLength) { - if (strIndex < str.length()) { + if (strIndex < str.size()) { if (m_maskData[i].separator) { s += m_maskData[i].maskChar; if (str[strIndex] == m_maskData[i].maskChar) @@ -1190,7 +1190,7 @@ QString QWidgetLineControl::maskString(int pos, const QString &str, bool clear) // search for separator first int n = findInMask(i, true, true, str[strIndex]); if (n != -1) { - if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) { + if (str.size() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) { s += QStringView{fill}.mid(i, n - i + 1); i = n + 1; // update i to find + 1 } @@ -1258,7 +1258,7 @@ QString QWidgetLineControl::stripString(const QString &str) const return str; QString s; - int end = qMin(m_maxLength, (int)str.length()); + int end = qMin(m_maxLength, (int)str.size()); for (int i = 0; i < end; ++i) if (m_maskData[i].separator) s += m_maskData[i].maskChar; @@ -1445,7 +1445,7 @@ void QWidgetLineControl::complete(int key) return; int n = 0; if (key == Qt::Key_Up || key == Qt::Key_Down) { - if (textAfterSelection().length()) + if (textAfterSelection().size()) return; QString prefix = hasSelectedText() ? textBeforeSelection() : text; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index eabe1d31c4..838a46fff6 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -115,7 +115,7 @@ public: bool isModified() const { return m_modifiedState != m_undoState; } void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; } - bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); } + bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.size(); } bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; } int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; } @@ -150,7 +150,7 @@ public: } int start() const { return 0; } - int end() const { return m_text.length(); } + int end() const { return m_text.size(); } #ifndef QT_NO_CLIPBOARD void copy(QClipboard::Mode mode = QClipboard::Clipboard) const; @@ -186,7 +186,7 @@ public: void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } void home(bool mark) { moveCursor(0, mark); } - void end(bool mark) { moveCursor(m_text.length(), mark); } + void end(bool mark) { moveCursor(m_text.size(), mark); } int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; QRect rectForPos(int pos) const; @@ -231,7 +231,7 @@ public: void backspace(); void del(); void deselect() { internalDeselect(); finishChange(); } - void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); } + void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.size(), true); } void insert(const QString &); void clear(); @@ -277,7 +277,7 @@ public: #endif int cursorPosition() const { return m_cursor; } - void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); } + void setCursorPosition(int pos) { if (pos <= m_text.size()) moveCursor(qMax(0, pos)); } bool hasAcceptableInput() const { return hasAcceptableInput(m_text); } bool fixup(); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index e9702e8977..1b78442ed1 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1403,7 +1403,7 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const if (relativePos == preeditPos) relativePos += preeditCursor; else if (relativePos > preeditPos) - relativePos += layout->preeditAreaText().length(); + relativePos += layout->preeditAreaText().size(); } QTextLine line = layout->lineForTextPosition(relativePos); @@ -1900,7 +1900,7 @@ bool QWidgetTextControlPrivate::sendMouseEventToInputContext( QTextLayout *layout = cursor.block().layout(); int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); - if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) + if (cursorPos < 0 || cursorPos > layout->preeditAreaText().size()) cursorPos = -1; if (cursorPos >= 0) { @@ -2060,7 +2060,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) QList<QTextLayout::FormatRange> overrides; overrides.reserve(e->attributes().size()); const int oldPreeditCursor = preeditCursor; - preeditCursor = e->preeditString().length(); + preeditCursor = e->preeditString().size(); hideCursor = false; for (int i = 0; i < e->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = e->attributes().at(i); @@ -2095,7 +2095,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) if (cursor.charFormat().isValid()) { int start = cursor.position() - block.position(); - int end = start + e->preeditString().length(); + int end = start + e->preeditString().size(); QList<QTextLayout::FormatRange>::iterator it = overrides.begin(); while (it != overrides.end()) { @@ -2168,7 +2168,7 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa QTextCursor tmpCursor = d->cursor; int localPos = d->cursor.position() - block.position(); QString result = block.text().mid(localPos); - while (result.length() < maxLength) { + while (result.size() < maxLength) { int currentBlock = tmpCursor.blockNumber(); tmpCursor.movePosition(QTextCursor::NextBlock); if (tmpCursor.blockNumber() == currentBlock) @@ -2475,12 +2475,12 @@ void QWidgetTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelectio Q_D(QWidgetTextControl); QMultiHash<int, int> hash; - for (int i = 0; i < d->extraSelections.count(); ++i) { + for (int i = 0; i < d->extraSelections.size(); ++i) { const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i); hash.insert(esel.cursor.anchor(), i); } - for (int i = 0; i < selections.count(); ++i) { + for (int i = 0; i < selections.size(); ++i) { const QTextEdit::ExtraSelection &sel = selections.at(i); const auto it = hash.constFind(sel.cursor.anchor()); if (it != hash.cend()) { @@ -2509,8 +2509,8 @@ void QWidgetTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelectio emit updateRequest(r); } - d->extraSelections.resize(selections.count()); - for (int i = 0; i < selections.count(); ++i) { + d->extraSelections.resize(selections.size()); + for (int i = 0; i < selections.size(); ++i) { d->extraSelections[i].cursor = selections.at(i).cursor; d->extraSelections[i].format = selections.at(i).format; } @@ -2520,7 +2520,7 @@ QList<QTextEdit::ExtraSelection> QWidgetTextControl::extraSelections() const { Q_D(const QWidgetTextControl); QList<QTextEdit::ExtraSelection> selections; - const int numExtraSelections = d->extraSelections.count(); + const int numExtraSelections = d->extraSelections.size(); selections.reserve(numExtraSelections); for (int i = 0; i < numExtraSelections; ++i) { QTextEdit::ExtraSelection sel; diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 3c41ed48a3..da49b5e5bc 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -728,7 +728,7 @@ int QDomNodeListPrivate::length() const that->createList(); } - return list.count(); + return list.size(); } /************************************************************** @@ -2628,7 +2628,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const int QDomNamedNodeMapPrivate::length() const { - return map.count(); + return map.size(); } bool QDomNamedNodeMapPrivate::contains(const QString& name) const @@ -3354,7 +3354,7 @@ QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(bool deep) int QDomCharacterDataPrivate::dataLength() const { - return value.length(); + return value.size(); } QString QDomCharacterDataPrivate::substringData(unsigned long offset, unsigned long n) const @@ -3612,7 +3612,7 @@ static QString encodeText(const QString &str, const bool encodeEOLs = false) { QString retval(str); - int len = retval.length(); + int len = retval.size(); int i = 0; while (i < len) { @@ -3640,8 +3640,8 @@ static QString encodeText(const QString &str, ati == QChar(0x9))) { const QString replacement(u"&#x"_s + QString::number(ati.unicode(), 16) + u';'); retval.replace(i, 1, replacement); - i += replacement.length(); - len += replacement.length() - 1; + i += replacement.size(); + len += replacement.size() - 1; } else if (encodeEOLs && ati == QChar(0xD)) { retval.replace(i, 1, "
"_L1); // Replace a single 0xD with a ref for 0xD len += 4; diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index 50819a3742..854059e7e7 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -1434,7 +1434,7 @@ void tst_QtConcurrentFilter::incrementalResults() QCOMPARE(future.isFinished(), true); QCOMPARE(future.resultCount(), count / 2); - QCOMPARE(future.results().count(), count / 2); + QCOMPARE(future.results().size(), count / 2); } void tst_QtConcurrentFilter::noDetach() diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index c842fa4341..52406e4a62 100644 --- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -221,7 +221,7 @@ void tst_QtConcurrentIterateKernel::throttling() QCOMPARE(iterations.loadRelaxed(), totalIterations); - QCOMPARE(threads.count(), 1); + QCOMPARE(threads.size(), 1); } class MultipleResultsFor : public IterateKernel<TestIterator, int> @@ -239,7 +239,7 @@ public: void tst_QtConcurrentIterateKernel::multipleResults() { QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously(); - QCOMPARE(f.results().count() , 10); + QCOMPARE(f.results().size() , 10); QCOMPARE(f.resultAt(0), 0); QCOMPARE(f.resultAt(5), 5); QCOMPARE(f.resultAt(9), 9); diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index a6c73777a1..d872702567 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -1956,7 +1956,7 @@ void tst_QtConcurrentMap::incrementalResults() QCOMPARE(future.isFinished(), true); QCOMPARE(future.resultCount(), count); - QCOMPARE(future.results().count(), count); + QCOMPARE(future.results().size(), count); } /* diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 6351854a21..97e13a2aa8 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -1383,7 +1383,7 @@ void tst_QtConcurrentRun::withPromiseAndThen() setFlag(syncEnd); future.waitForFinished(); - QCOMPARE(future.results().count(), 0); + QCOMPARE(future.results().size(), 0); QVERIFY(runExecuted); QVERIFY(!cancelReceivedBeforeSync); QVERIFY(cancelReceivedAfterSync); @@ -1403,7 +1403,7 @@ void tst_QtConcurrentRun::withPromiseAndThen() setFlag(syncEnd); resultFuture.waitForFinished(); - QCOMPARE(future.results().count(), 1); + QCOMPARE(future.results().size(), 1); QCOMPARE(future.result(), 1); QVERIFY(runExecuted); QVERIFY(thenExecuted); @@ -1426,7 +1426,7 @@ void tst_QtConcurrentRun::withPromiseAndThen() setFlag(syncEnd); resultFuture.waitForFinished(); - QCOMPARE(future.results().count(), 0); + QCOMPARE(future.results().size(), 0); QVERIFY(runExecuted); QVERIFY(!thenExecuted); QVERIFY(cancelExecuted); diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp index 701b086ab8..51a2273f9d 100644 --- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp @@ -234,7 +234,7 @@ void tst_QtConcurrentThreadEngine::threadCount() const int repeats = 10; for (int i = 0; i < repeats; ++i) { (new ThreadCountUser())->startAsynchronously().waitForFinished(); - const auto count = threads.count(); + const auto count = threads.size(); const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount(); QVERIFY(count <= maxThreadCount); QVERIFY(!threads.contains(QThread::currentThread())); @@ -243,7 +243,7 @@ void tst_QtConcurrentThreadEngine::threadCount() // Set the finish flag immediately, this should give us one thread only. for (int i = 0; i < repeats; ++i) { (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished(); - const auto count = threads.count(); + const auto count = threads.size(); QCOMPARE(count, 1); QVERIFY(!threads.contains(QThread::currentThread())); } @@ -271,7 +271,7 @@ void tst_QtConcurrentThreadEngine::multipleResults() { MultipleResultsUser *engine = new MultipleResultsUser(); QFuture<int> f = engine->startAsynchronously(); - QCOMPARE(f.results().count() , 10); + QCOMPARE(f.results().size() , 10); QCOMPARE(f.resultAt(0), 0); QCOMPARE(f.resultAt(5), 5); QCOMPARE(f.resultAt(9), 9); diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 162f8ea9fc..af84961531 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -109,7 +109,7 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(group.state(), QAnimationGroup::Stopped); group.start(); - QCOMPARE(groupStateChangedSpy.count(), 2); + QCOMPARE(groupStateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -121,7 +121,7 @@ void tst_QAnimationGroup::emptyGroup() QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimation::pause: Cannot pause a stopped animation"); group.pause(); - QCOMPARE(groupStateChangedSpy.count(), 2); + QCOMPARE(groupStateChangedSpy.size(), 2); QCOMPARE(group.state(), QAnimationGroup::Stopped); group.start(); @@ -135,7 +135,7 @@ void tst_QAnimationGroup::emptyGroup() group.stop(); - QCOMPARE(groupStateChangedSpy.count(), 4); + QCOMPARE(groupStateChangedSpy.size(), 4); QCOMPARE(group.state(), QAnimationGroup::Stopped); } diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 6d73725cff..3c5d9ed3a9 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -234,38 +234,38 @@ void tst_QParallelAnimationGroup::stateChanged() //first; let's start forward group.start(); //all the animations should be started - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); - QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim1 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); - QCOMPARE(spy2.count(), 1); //no change - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy2.size(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(2500); //anim2 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 2); //no change - QCOMPARE(spy2.count(), 2); + QCOMPARE(spy1.size(), 2); //no change + QCOMPARE(spy2.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(3500); //everything should be finished QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(spy1.count(), 2); //no change - QCOMPARE(spy2.count(), 2); //no change - QCOMPARE(spy3.count(), 2); + QCOMPARE(spy1.size(), 2); //no change + QCOMPARE(spy2.size(), 2); //no change + QCOMPARE(spy3.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); - QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); //cleanup @@ -280,38 +280,38 @@ void tst_QParallelAnimationGroup::stateChanged() //only anim3 and anim4 should be started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy1.size(), 0); + QCOMPARE(spy2.size(), 0); + QCOMPARE(spy3.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); - QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim2 should be started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 0); //no change - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 0); //no change + QCOMPARE(spy2.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(500); //anim1 is finally also started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); - QCOMPARE(spy2.count(), 1); //no change - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy2.size(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(0); //everything should be stopped QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); - QCOMPARE(spy2.count(), 2); + QCOMPARE(spy2.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); - QCOMPARE(spy3.count(), 2); + QCOMPARE(spy3.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); - QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); } @@ -405,8 +405,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); - QCOMPARE(groupStateChangedSpy.count(), 0); - QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(groupStateChangedSpy.size(), 0); + QCOMPARE(childStateChangedSpy.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim.state(), QAnimationGroup::Stopped); @@ -417,8 +417,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -428,8 +428,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() // starting directly a running child will not have any effect anim.start(); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); anim.pause(); @@ -572,8 +572,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); - QCOMPARE(stateChangedSpy1.count(), 0); - QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); + QCOMPARE(stateChangedSpy2.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim1.state(), QAnimationGroup::Stopped); QCOMPARE(anim2.state(), QAnimationGroup::Stopped); @@ -598,13 +598,13 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() group.start(); - QCOMPARE(stateChangedSpy1.count(), 3); + QCOMPARE(stateChangedSpy1.size(), 3); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), @@ -655,22 +655,22 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.addAnimation(&anim1); group.addAnimation(&anim2); group.addAnimation(&anim3); - QCOMPARE(stateChangedSpy1.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); group.start(); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(finishedSpy1.count(), 1); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(finishedSpy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(finishedSpy2.count(), 0); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(finishedSpy2.size(), 0); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy3.count(), 1); - QCOMPARE(finishedSpy3.count(), 0); + QCOMPARE(stateChangedSpy3.size(), 1); + QCOMPARE(finishedSpy3.size(), 0); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()), QAnimationGroup::Running); @@ -688,21 +688,21 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() stateChangedSpy3.clear(); group.start(); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(stateChangedSpy3.count(), 1); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(stateChangedSpy3.size(), 1); group.setCurrentTime(50); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(stateChangedSpy3.count(), 2); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(stateChangedSpy3.size(), 2); group.setCurrentTime(150); - QCOMPARE(stateChangedSpy1.count(), 4); - QCOMPARE(stateChangedSpy2.count(), 3); - QCOMPARE(stateChangedSpy3.count(), 4); + QCOMPARE(stateChangedSpy1.size(), 4); + QCOMPARE(stateChangedSpy2.size(), 3); + QCOMPARE(stateChangedSpy3.size(), 4); group.setCurrentTime(50); - QCOMPARE(stateChangedSpy1.count(), 6); - QCOMPARE(stateChangedSpy2.count(), 5); - QCOMPARE(stateChangedSpy3.count(), 6); + QCOMPARE(stateChangedSpy1.size(), 6); + QCOMPARE(stateChangedSpy2.size(), 5); + QCOMPARE(stateChangedSpy3.size(), 6); } @@ -734,7 +734,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() group.start(); - QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), @@ -943,7 +943,7 @@ void tst_QParallelAnimationGroup::pauseResume() QTest::qWait(100); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); const int currentTime = group.currentLoopTime(); QCOMPARE(anim->currentLoopTime(), currentTime); @@ -953,7 +953,7 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); group.resume(); @@ -961,21 +961,21 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); group.stop(); spy.clear(); new TestAnimation2(500, &group); group.start(); - QCOMPARE(spy.count(), 1); //the animation should have been started + QCOMPARE(spy.size(), 1); //the animation should have been started QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running); group.setCurrentTime(250); //end of first animation - QCOMPARE(spy.count(), 2); //the animation should have been stopped + QCOMPARE(spy.size(), 2); //the animation should have been stopped QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped); group.pause(); - QCOMPARE(spy.count(), 2); //this shouldn't have changed + QCOMPARE(spy.size(), 2); //this shouldn't have changed group.resume(); - QCOMPARE(spy.count(), 2); //this shouldn't have changed + QCOMPARE(spy.size(), 2); //this shouldn't have changed } // This is a regression test for QTBUG-8910, where a crash occurred when the diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index a5eff80e49..d739164a10 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -283,9 +283,9 @@ void tst_QPropertyAnimation::statesAndSignals() anim->setCurrentTime(1); anim->setCurrentTime(100); - QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(currentLoopSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(currentLoopSpy.size(), 0); QCOMPARE(anim->state(), QAnimationGroup::Stopped); anim->setLoopCount(3); @@ -294,26 +294,26 @@ void tst_QPropertyAnimation::statesAndSignals() if (uncontrolled) QSKIP("Uncontrolled animations don't handle looping"); - QCOMPARE(currentLoopSpy.count(), 1); + QCOMPARE(currentLoopSpy.size(), 1); QCOMPARE(anim->currentLoop(), 1); anim->setCurrentTime(0); - QCOMPARE(currentLoopSpy.count(), 2); + QCOMPARE(currentLoopSpy.size(), 2); QCOMPARE(anim->currentLoop(), 0); anim->start(); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); //anim must have started + QCOMPARE(runningSpy.size(), 1); //anim must have started QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); anim->stop(); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 1); //anim must have stopped - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); //anim must have stopped + QCOMPARE(finishedSpy.size(), 0); QCOMPARE(anim->currentLoopTime(), 0); QCOMPARE(anim->currentLoop(), 0); - QCOMPARE(currentLoopSpy.count(), 2); + QCOMPARE(currentLoopSpy.size(), 2); runningSpy.clear(); { @@ -321,30 +321,30 @@ void tst_QPropertyAnimation::statesAndSignals() anim->start(); timeDriver.wait(1000); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 2); //started and stopped again + QCOMPARE(runningSpy.size(), 2); //started and stopped again runningSpy.clear(); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(finishedSpy.size(), 1); QCOMPARE(anim->currentLoopTime(), 100); QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(currentLoopSpy.count(), 4); + QCOMPARE(currentLoopSpy.size(), 4); anim->start(); // auto-rewinds QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentTime(), 0); QCOMPARE(anim->currentLoop(), 0); - QCOMPARE(currentLoopSpy.count(), 5); - QCOMPARE(runningSpy.count(), 1); // anim has started - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(currentLoopSpy.size(), 5); + QCOMPARE(runningSpy.size(), 1); // anim has started + QCOMPARE(finishedSpy.size(), 1); QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); timeDriver.wait(1000); - QCOMPARE(currentLoopSpy.count(), 7); + QCOMPARE(currentLoopSpy.size(), 7); QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(runningSpy.count(), 1); // anim has stopped - QCOMPARE(finishedSpy.count(), 2); + QCOMPARE(runningSpy.size(), 1); // anim has stopped + QCOMPARE(finishedSpy.size(), 2); QCOMPARE(anim->currentLoopTime(), 100); } } @@ -364,8 +364,8 @@ void tst_QPropertyAnimation::deletion1() anim->setEndValue(20); anim->setDuration(200); anim->start(); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); @@ -375,8 +375,8 @@ void tst_QPropertyAnimation::deletion1() timeDriver.wait(150); QVERIFY(anim); //The animation should not have been deleted QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(runningSpy.size(), 2); + QCOMPARE(finishedSpy.size(), 1); anim->start(QVariantAnimation::DeleteWhenStopped); QVERIFY(anim); @@ -385,8 +385,8 @@ void tst_QPropertyAnimation::deletion1() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); timeDriver.wait(150); - QCOMPARE(runningSpy.count(), 4); - QCOMPARE(finishedSpy.count(), 2); + QCOMPARE(runningSpy.size(), 4); + QCOMPARE(finishedSpy.size(), 2); QVERIFY(!anim); //The animation must have been deleted delete object; } @@ -417,8 +417,8 @@ void tst_QPropertyAnimation::deletion2() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop QTimer::singleShot(0, object, SLOT(deleteLater())); @@ -451,11 +451,11 @@ void tst_QPropertyAnimation::deletion3() timeDriver.wait(50); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); delete anim; - QCOMPARE(runningSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 2); + QCOMPARE(finishedSpy.size(), 0); } void tst_QPropertyAnimation::duration0() @@ -547,7 +547,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); timeDriver.wait(anim->duration()); - QCOMPARE(runningSpy.count(), 2); //started and then stopped + QCOMPARE(runningSpy.size(), 2); //started and then stopped QVERIFY(!anim); } { @@ -559,7 +559,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() timeDriver.wait(anim->duration()/2); QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole"); anim2->setEndValue(100); - QCOMPARE(runningSpy.count(), 1); + QCOMPARE(runningSpy.size(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); //anim2 will interrupt anim1 @@ -908,7 +908,7 @@ void tst_QPropertyAnimation::zeroDurationStart() anim.start(); //the animation stops immediately QCOMPARE(anim.state(), QAbstractAnimation::Stopped); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); //let's check the first state change const QVariantList firstChange = spy.first(); @@ -1193,8 +1193,8 @@ void tst_QPropertyAnimation::valueChanged() QCOMPARE(anim.currentTime(), anim.duration()); //let's check that the values go forward - QCOMPARE(spy.count(), 6); //we should have got everything from 0 to 5 - for (int i = 0; i < spy.count(); ++i) { + QCOMPARE(spy.size(), 6); //we should have got everything from 0 to 5 + for (int i = 0; i < spy.size(); ++i) { QCOMPARE(qvariant_cast<QVariant>(spy.at(i).first()).toInt(), i); } } @@ -1324,15 +1324,15 @@ void tst_QPropertyAnimation::zeroLoopCount() QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentValue().toInt(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 0); anim->start(); QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentValue().toInt(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 0); } diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 61be0d00f5..e6e8731378 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -551,8 +551,8 @@ using StateList = QList<QAbstractAnimation::State>; static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates) { bool equals = true; - for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { - if (i >= spy.count() || i >= expectedStates.count()) { + for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) { + if (i >= spy.size() || i >= expectedStates.size()) { equals = false; break; } @@ -567,14 +567,14 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates if (!equals) { const char *stateStrings[] = {"Stopped", "Paused", "Running"}; QString e,a; - for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { - if (i < expectedStates.count()) { + for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) { + if (i < expectedStates.size()) { int exp = int(expectedStates.at(i)); if (!e.isEmpty()) e += QLatin1String(", "); e += QLatin1String(stateStrings[exp]); } - if (i < spy.count()) { + if (i < spy.size()) { QList<QVariant> args = spy.at(i); QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.value(1)); if (!a.isEmpty()) @@ -589,7 +589,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } qDebug("\n" "expected (count == %zd): %s\n" - "actual (count == %zd): %s\n", size_t(expectedStates.count()), qPrintable(e), size_t(spy.count()), qPrintable(a)); + "actual (count == %zd): %s\n", size_t(expectedStates.size()), qPrintable(e), size_t(spy.size()), qPrintable(a)); } return equals; } @@ -636,8 +636,8 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); - QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped - QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused + QCOMPARE(a1StateChangedSpy.size(), 5); // Running,Paused,Stopped,Running,Stopped + QCOMPARE(seqStateChangedSpy.size(), 2); // Running,Paused QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Paused @@ -678,7 +678,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentLoopTime() >= 1); - QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running + QCOMPARE(seqStateChangedSpy.size(), 3); // Running,Paused,Running QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()), QAnimationGroup::Running); @@ -699,13 +699,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentLoopTime() >= 1); - QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused + QCOMPARE(seqStateChangedSpy.size(), 4); // Running,Paused,Running,Paused QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()), QAnimationGroup::Paused); group.stop(); - QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped + QCOMPARE(seqStateChangedSpy.size(), 5); // Running,Paused,Running,Paused,Stopped QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()), QAnimationGroup::Stopped); } @@ -749,7 +749,7 @@ void tst_QSequentialAnimationGroup::restart() QTRY_COMPARE(group.state(), QAnimationGroup::Stopped); for (int i = 0; i < 3; i++) { - QCOMPARE(animsStateChanged[i]->count(), 4); + QCOMPARE(animsStateChanged[i]->size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()), @@ -760,22 +760,22 @@ void tst_QSequentialAnimationGroup::restart() QAnimationGroup::Stopped); } - QCOMPARE(seqStateChangedSpy.count(), 2); + QCOMPARE(seqStateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); - for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++) + QCOMPARE(seqCurrentAnimChangedSpy.size(), 6); + for(int i=0; i<seqCurrentAnimChangedSpy.size(); i++) QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qvariant_cast<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0))); group.start(); - QCOMPARE(animsStateChanged[0]->count(), 5); - QCOMPARE(animsStateChanged[1]->count(), 4); - QCOMPARE(animsStateChanged[2]->count(), 4); - QCOMPARE(seqStateChangedSpy.count(), 3); + QCOMPARE(animsStateChanged[0]->size(), 5); + QCOMPARE(animsStateChanged[1]->size(), 4); + QCOMPARE(animsStateChanged[2]->size(), 4); + QCOMPARE(seqStateChangedSpy.size(), 3); } void tst_QSequentialAnimationGroup::looping() @@ -831,21 +831,21 @@ void tst_QSequentialAnimationGroup::looping() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); - QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped + QCOMPARE(a1Spy.size(), 5); // Running,Paused,Stopped,Running,Stopped QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Paused << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Stopped))); - QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped + QCOMPARE(a2Spy.size(), 4); // Running,Stopped,Running,Stopped QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Paused))); - QCOMPARE(seqSpy.count(), 2); // Running,Paused - QCOMPARE(groupSpy.count(), 2); // Running,Paused + QCOMPARE(seqSpy.size(), 2); // Running,Paused + QCOMPARE(groupSpy.size(), 2); // Running,Paused // Looping, current time = duration + 1 group.setCurrentTime(group.duration() + 1); @@ -866,8 +866,8 @@ void tst_QSequentialAnimationGroup::looping() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Stopped); - QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped - QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped + QCOMPARE(a1Spy.size(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped + QCOMPARE(a2Spy.size(), 4); // Running, Stopped, Running, Stopped QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Stopped << QAbstractAnimation::Running @@ -878,7 +878,7 @@ void tst_QSequentialAnimationGroup::looping() << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Paused))); - QCOMPARE(groupSpy.count(), 2); + QCOMPARE(groupSpy.size(), 2); } void tst_QSequentialAnimationGroup::startDelay() @@ -1077,8 +1077,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); - QCOMPARE(groupStateChangedSpy.count(), 0); - QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(groupStateChangedSpy.size(), 0); + QCOMPARE(childStateChangedSpy.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim.state(), QAnimationGroup::Stopped); @@ -1089,8 +1089,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -1100,8 +1100,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() // starting directly a running child will not have any effect anim.start(); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); anim.pause(); @@ -1244,8 +1244,8 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); - QCOMPARE(stateChangedSpy1.count(), 0); - QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); + QCOMPARE(stateChangedSpy2.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim1->state(), QAnimationGroup::Stopped); QCOMPARE(anim2->state(), QAnimationGroup::Stopped); @@ -1283,7 +1283,7 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim2->state(), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), @@ -1323,7 +1323,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.setLoopCount(2); group.start(); - QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), @@ -1400,7 +1400,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() const int actualDuration = notTimeDriven.currentLoopTime(); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(group.currentLoopTime(), actualDuration); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); //2nd case: // lets make sure the seeking will work again @@ -1416,29 +1416,29 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() //3rd case: //now let's add a perfectly defined animation at the end - QCOMPARE(animStateChangedSpy.count(), 0); + QCOMPARE(animStateChangedSpy.size(), 0); group.start(); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); QCOMPARE(group.currentLoopTime(), 0); QCOMPARE(notTimeDriven.currentLoopTime(), 0); - QCOMPARE(animStateChangedSpy.count(), 0); + QCOMPARE(animStateChangedSpy.size(), 0); QTest::qWait(300); //wait for the end of notTimeDriven QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); - QCOMPARE(animStateChangedSpy.count(), 1); + QCOMPARE(animStateChangedSpy.size(), 1); QTest::qWait(300); //wait for the end of anim QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped); QCOMPARE(anim.currentLoopTime(), anim.duration()); //we should simply be at the end - QCOMPARE(spy.count(), 1); - QCOMPARE(animStateChangedSpy.count(), 2); + QCOMPARE(spy.size(), 1); + QCOMPARE(animStateChangedSpy.size(), 2); QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime()); } @@ -1623,7 +1623,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QTest::qWait(100); QTRY_COMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); const int currentTime = group.currentLoopTime(); QCOMPARE(anim->currentLoopTime(), currentTime); @@ -1633,7 +1633,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); group.resume(); @@ -1641,7 +1641,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QSequentialAnimationGroup::bindings() @@ -1667,18 +1667,18 @@ void tst_QSequentialAnimationGroup::bindings() group.setCurrentTime(int(totalDuration * 0.5 / 3)); QCOMPARE(currentAnim.value(), anim1.get()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); group.setCurrentTime(int(totalDuration * 1.5 / 3)); QCOMPARE(currentAnim.value(), anim2.get()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // change to other style of formulating a binding to test both currentAnim.setBinding(group.bindableCurrentAnimation().makeBinding()); group.setCurrentTime(int(totalDuration * 2.5 / 3)); QCOMPARE(currentAnim.value(), anim3.get()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); // currentAnimation is read-only. Binding it to something should have no effect QProperty<QAbstractAnimation *> leader; diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index f914ee5f23..832319a652 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -191,7 +191,7 @@ void tst_QGetPutEnv::intValue() bool actualOk = !ok; // Self-test: confirm that it was like the docs said it should be - if (value.length() < maxlen) { + if (value.size() < maxlen) { QCOMPARE(value.toInt(&actualOk, 0), expected); QCOMPARE(actualOk, ok); } diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 752fb948a5..9f5b227695 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -84,7 +84,7 @@ void tst_QGlobal::for_each() foreach(int i, list) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // do it again, to make sure we don't have any for-scoping // problems with older compilers @@ -92,21 +92,21 @@ void tst_QGlobal::for_each() foreach(int i, list) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // check whether we can pass a constructor as container argument counter = 0; foreach (int i, QList<int>(list)) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // check whether we can use a lambda counter = 0; foreach (int i, [&](){ return list; }()) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // Should also work with an existing variable int local = 0; @@ -114,7 +114,7 @@ void tst_QGlobal::for_each() foreach (local, list) { QCOMPARE(local, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); QCOMPARE(local, counter - 1); // Test the macro does not mess if/else conditions @@ -124,7 +124,7 @@ void tst_QGlobal::for_each() QCOMPARE(i, counter++); else QFAIL("If/Else mismatch"); - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); counter = 0; if (false) @@ -135,7 +135,7 @@ void tst_QGlobal::for_each() foreach (int i, list) if (false) { } else QCOMPARE(i, counter++); - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // break and continue counter = 0; diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 810e2ceb84..65a7daaf7d 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -521,12 +521,12 @@ void tst_QDir::removeRecursively_data() << tmpdir + "two/three" << "relative"; QDir dir; - for (int i = 0; i < dirs.count(); ++i) + for (int i = 0; i < dirs.size(); ++i) dir.mkpath(dirs.at(i)); QStringList files; files << tmpdir + "one/file"; files << tmpdir + "two/three/file"; - for (int i = 0; i < files.count(); ++i) { + for (int i = 0; i < files.size(); ++i) { QFile file(files.at(i)); QVERIFY(file.open(QIODevice::WriteOnly)); file.write("Hello"); @@ -1045,7 +1045,7 @@ void tst_QDir::entryListSimple() QDir dir(dirName); QStringList actual = dir.entryList(); - QVERIFY2(actual.count() >= countMin, msgEntryListFailed(actual.count(), countMin, dirName).constData()); + QVERIFY2(actual.size() >= countMin, msgEntryListFailed(actual.size(), countMin, dirName).constData()); } void tst_QDir::entryListWithSymLinks() @@ -1254,11 +1254,11 @@ void tst_QDir::setNameFilters() dir.setNameFilters(nameFilters); QStringList actual = dir.entryList(); - int max = qMin(actual.count(), expected.count()); + int max = qMin(actual.size(), expected.size()); for (int i=0; i<max; ++i) QCOMPARE(actual[i], expected[i]); - QCOMPARE(actual.count(), expected.count()); + QCOMPARE(actual.size(), expected.size()); } void @@ -1734,7 +1734,7 @@ void tst_QDir::homePath() QVERIFY(QDir::isAbsolutePath(strHome)); #ifdef Q_OS_UNIX - if (strHome.length() > 1) // root dir = "/" + if (strHome.size() > 1) // root dir = "/" QVERIFY(!strHome.endsWith('/')); QByteArray envHome = qgetenv("HOME"); @@ -1748,7 +1748,7 @@ void tst_QDir::homePath() #endif QStringList entries = homeDir.entryList(); - for (int i = 0; i < entries.count(); ++i) { + for (int i = 0; i < entries.size(); ++i) { QFileInfo fi(QDir::homePath() + "/" + entries[i]); QCOMPARE(fi.exists(), true); } @@ -1764,7 +1764,7 @@ void tst_QDir::tempPath() QVERIFY(QDir::isAbsolutePath(path)); #ifdef Q_OS_UNIX - if (path.length() > 1) // root dir = "/" + if (path.size() > 1) // root dir = "/" QVERIFY(!path.endsWith('/')); #elif defined(Q_OS_WIN) if (path.length() > 3) // root dir = "c:/"; "//" is not really valid... @@ -1845,10 +1845,10 @@ void tst_QDir::searchPaths() QFETCH(QString, expectedAbsolutePath); bool exists = !expectedAbsolutePath.isEmpty(); - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QDir::setSearchPaths(searchPathPrefixList.at(i), searchPathsList.at(i).split(",")); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(",")); } @@ -1859,19 +1859,19 @@ void tst_QDir::searchPaths() QCOMPARE(QFileInfo(filename).absoluteFilePath(), expectedAbsolutePath); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QDir::setSearchPaths(searchPathPrefixList.at(i), QStringList()); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty()); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { foreach (QString path, searchPathsList.at(i).split(",")) { QDir::addSearchPath(searchPathPrefixList.at(i), path); } } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(",")); } @@ -1882,10 +1882,10 @@ void tst_QDir::searchPaths() QCOMPARE(QFileInfo(filename).absoluteFilePath(), expectedAbsolutePath); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QDir::setSearchPaths(searchPathPrefixList.at(i), QStringList()); } - for (int i = 0; i < searchPathPrefixList.count(); ++i) { + for (int i = 0; i < searchPathPrefixList.size(); ++i) { QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty()); } } @@ -2212,7 +2212,7 @@ void tst_QDir::drives() } QCOMPARE(foundsystem, true); #else - QCOMPARE(list.count(), 1); //root + QCOMPARE(list.size(), 1); //root QCOMPARE(list.at(0).absolutePath(), QLatin1String("/")); #endif } @@ -2224,7 +2224,7 @@ void tst_QDir::arrayOperator() QStringList entries(dir1.entryList()); int i = dir2.count(); - QCOMPARE(i, entries.count()); + QCOMPARE(i, entries.size()); --i; for (;i>=0;--i) { QCOMPARE(dir2[i], entries.at(i)); @@ -2477,7 +2477,7 @@ void tst_QDir::stdfilesystem() QCOMPARE(entries, QStringList() << "subdir2" << "subdir1"); QCOMPARE(filteredDir.sorting(), QDir::SortFlag::Reversed); QCOMPARE(filteredDir.filter(), QDir::Filter::Dirs); - QCOMPARE(filteredDir.nameFilters().length(), 1); + QCOMPARE(filteredDir.nameFilters().size(), 1); QCOMPARE(filteredDir.nameFilters().first(), "subdir*"); } #else diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index bed78e7529..303c2c9dcf 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -531,7 +531,7 @@ void tst_QDirIterator::longPath() QCOMPARE(n, m); dirName.chop(1); - while (dirName.length() > 0 && dir.exists(dirName) && dir.rmdir(dirName)) { + while (dirName.size() > 0 && dir.exists(dirName) && dir.rmdir(dirName)) { dirName.chop(1); } dir.cdUp(); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index acf26039d1..5acab6e473 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -147,8 +147,8 @@ void tst_QFileSystemWatcher::basicTest() testFile.close(); // waiting max 5 seconds for notification for file modification to trigger - QTRY_COMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QTRY_COMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QString fileName = changedSpy.at(0).at(0).toString(); QCOMPARE(fileName, testFile.fileName()); @@ -165,7 +165,7 @@ void tst_QFileSystemWatcher::basicTest() timer.start(5000); eventLoop.exec(); - QCOMPARE(changedSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); // readd the file watch with a relative path const QString relativeTestFileName = QDir::current().relativeFilePath(testFile.fileName()); @@ -175,7 +175,7 @@ void tst_QFileSystemWatcher::basicTest() testFile.write(QByteArray("hello multiverse!")); testFile.close(); - QTRY_VERIFY(changedSpy.count() > 0); + QTRY_VERIFY(changedSpy.size() > 0); QVERIFY(watcher.removePath(relativeTestFileName)); @@ -191,8 +191,8 @@ void tst_QFileSystemWatcher::basicTest() #if !defined(Q_OS_QNX) // waiting max 5 seconds for notification for file permission modification to trigger - QTRY_COMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QTRY_COMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); fileName = changedSpy.at(0).at(0).toString(); QCOMPARE(fileName, testFile.fileName()); @@ -209,7 +209,7 @@ void tst_QFileSystemWatcher::basicTest() timer.start(5000); eventLoop.exec(); - QCOMPARE(changedSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); // readd the file watch QVERIFY(watcher.addPath(testFile.fileName())); @@ -220,8 +220,8 @@ void tst_QFileSystemWatcher::basicTest() // waiting max 5 seconds for notification for file removal to trigger // > 0 && < 3 because some platforms may emit two changes // XXX: which platforms? (QTBUG-23370) - QTRY_VERIFY(changedSpy.count() > 0 && changedSpy.count() < 3); - QCOMPARE(changedSpy.at(0).count(), 1); + QTRY_VERIFY(changedSpy.size() > 0 && changedSpy.size() < 3); + QCOMPARE(changedSpy.at(0).size(), 1); fileName = changedSpy.at(0).at(0).toString(); QCOMPARE(fileName, testFile.fileName()); @@ -237,7 +237,7 @@ void tst_QFileSystemWatcher::basicTest() timer.start(5000); eventLoop.exec(); - QCOMPARE(changedSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); QVERIFY(testFile.remove()); } @@ -301,7 +301,7 @@ void tst_QFileSystemWatcher::watchDirectory() timer.start(5000); eventLoop.exec(); - QCOMPARE(changedSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); QVERIFY(watcher.addPaths(testDirs).isEmpty()); @@ -321,10 +321,10 @@ void tst_QFileSystemWatcher::watchDirectory() signalCounter[testDirName] = 0; // waiting max 5 seconds for notification for directory removal to trigger - QTRY_COMPARE(changedSpy.count(), testDirs.size() * 2); - for (int i = 0; i < changedSpy.count(); i++) { + QTRY_COMPARE(changedSpy.size(), testDirs.size() * 2); + for (int i = 0; i < changedSpy.size(); i++) { const auto &signal = changedSpy.at(i); - QCOMPARE(signal.count(), 1); + QCOMPARE(signal.size(), 1); auto it = signalCounter.find(signal.at(0).toString()); QVERIFY(it != signalCounter.end()); @@ -352,7 +352,7 @@ void tst_QFileSystemWatcher::watchDirectory() timer.start(5000); eventLoop.exec(); - QCOMPARE(changedSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); for (const auto &testDirName : testDirs) QVERIFY(temporaryDir.rmdir(testDirName)); @@ -364,12 +364,12 @@ void tst_QFileSystemWatcher::addPath() QFileSystemWatcher watcher; QString home = QDir::homePath(); QVERIFY(watcher.addPath(home)); - QCOMPARE(watcher.directories().count(), 1); + QCOMPARE(watcher.directories().size(), 1); QCOMPARE(watcher.directories().first(), home); // second watch on an already-watched path should fail QVERIFY(!watcher.addPath(home)); - QCOMPARE(watcher.directories().count(), 1); + QCOMPARE(watcher.directories().size(), 1); // With empty string QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::addPath: path is empty"); @@ -382,9 +382,9 @@ void tst_QFileSystemWatcher::removePath() QString home = QDir::homePath(); QVERIFY(watcher.addPath(home)); QVERIFY(watcher.removePath(home)); - QCOMPARE(watcher.directories().count(), 0); + QCOMPARE(watcher.directories().size(), 0); QVERIFY(!watcher.removePath(home)); - QCOMPARE(watcher.directories().count(), 0); + QCOMPARE(watcher.directories().size(), 0); // With empty string QTest::ignoreMessage(QtWarningMsg, "QFileSystemWatcher::removePath: path is empty"); @@ -397,7 +397,7 @@ void tst_QFileSystemWatcher::addPaths() QStringList paths; paths << QDir::homePath() << QDir::tempPath(); QCOMPARE(watcher.addPaths(paths), QStringList()); - QCOMPARE(watcher.directories().count(), 2); + QCOMPARE(watcher.directories().size(), 2); // With empty list paths.clear(); @@ -465,9 +465,9 @@ void tst_QFileSystemWatcher::removePaths() QStringList paths; paths << QDir::homePath() << QDir::tempPath(); QCOMPARE(watcher.addPaths(paths), QStringList()); - QCOMPARE(watcher.directories().count(), 2); + QCOMPARE(watcher.directories().size(), 2); QCOMPARE(watcher.removePaths(paths), QStringList()); - QCOMPARE(watcher.directories().count(), 0); + QCOMPARE(watcher.directories().size(), 0); //With empty list paths.clear(); @@ -556,7 +556,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QTest::qWait(2000); #endif - QTRY_VERIFY(fileChangedSpy.count() > 0); + QTRY_VERIFY(fileChangedSpy.size() > 0); QVERIFY2(dirChangedSpy.count() == 0, dirChangedSpy.receivedFilesMessage()); fileChangedSpy.clear(); @@ -567,7 +567,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); - int fileChangedSpyCount = fileChangedSpy.count(); + int fileChangedSpyCount = fileChangedSpy.size(); #ifdef Q_OS_WIN if (fileChangedSpyCount != 0) QEXPECT_FAIL("", "See QTBUG-30943", Continue); @@ -579,7 +579,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(QFile::remove(testFileName)); - QTRY_VERIFY(fileChangedSpy.count() > 0); + QTRY_VERIFY(fileChangedSpy.size() > 0); QTRY_COMPARE(dirChangedSpy.count(), 1); fileChangedSpy.clear(); @@ -591,7 +591,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); - QCOMPARE(fileChangedSpy.count(), 0); + QCOMPARE(fileChangedSpy.size(), 0); QCOMPARE(dirChangedSpy.count(), 1); // QTBUG-61792, removal should succeed (bug on Windows which uses one change @@ -694,7 +694,7 @@ void tst_QFileSystemWatcher::QTBUG2331() // remove directory, we should get one change signal, and we should no longer // be watching the directory. QVERIFY(temporaryDirectory.remove()); - QTRY_COMPARE(changedSpy.count(), 1); + QTRY_COMPARE(changedSpy.size(), 1); QCOMPARE(watcher.directories(), QStringList()); } #endif // QT_BUILD_INTERNAL diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 07c2aa27b7..2eb927c429 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -174,13 +174,13 @@ void tst_QIODevice::read_QByteArray() f.open(QIODevice::ReadOnly); QByteArray b = f.read(10); - QCOMPARE(b.length(), 10); + QCOMPARE(b.size(), 10); b = f.read(256); - QCOMPARE(b.length(), 256); + QCOMPARE(b.size(), 256); b = f.read(0); - QCOMPARE(b.length(), 0); + QCOMPARE(b.size(), 0); } //-------------------------------------------------------------------- diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index a0a9bb940e..cddaff8957 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -78,7 +78,7 @@ public: { QString ret; QTextStream out(&ret); - for (int a = 0; a < _configitemEntryOrder.count(); a++) { + for (int a = 0; a < _configitemEntryOrder.size(); a++) { out << _configitemEntryOrder[a] << " = " << _values.value(_configitemEntryOrder[a]) << Qt::endl; @@ -153,7 +153,7 @@ inline QString cleanLogLine(const QString &qstring) buf.remove("../"); buf.remove("qlog/"); QString ret; - for (int i = 0; i < buf.length(); i++) { + for (int i = 0; i < buf.size(); i++) { if (buf[i] >= '!' && buf[i] <= 'z') ret += buf[i]; } @@ -903,7 +903,7 @@ private slots: buf = QStringLiteral("Digia.Berlin.Office.com.debug: Berlin \"from Thread 2\" :false"); compareagainst.append(cleanLogLine(buf)); - for (int i = 0; i < threadtest.count(); i++) { + for (int i = 0; i < threadtest.size(); i++) { if (!compareagainst.contains(cleanLogLine(threadtest[i]))){ fprintf(stdout, "%s\r\n", threadtest[i].toLatin1().constData()); QVERIFY2(false, "Multithread log is not complete!"); diff --git a/tests/auto/corelib/io/qprocess/testDetached/main.cpp b/tests/auto/corelib/io/qprocess/testDetached/main.cpp index 57d39f4f13..4282621f0b 100644 --- a/tests/auto/corelib/io/qprocess/testDetached/main.cpp +++ b/tests/auto/corelib/io/qprocess/testDetached/main.cpp @@ -41,7 +41,7 @@ struct Args static Args parseArguments(const QStringList &args) { Args result; - if (args.count() < 2) { + if (args.size() < 2) { result.exitCode = 128; result.errorMessage = "Usage: testDetached [--out-channel={stdout|stderr}] filename.txt\n"; return result; diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index a2b3dfc154..5b575ce54a 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -244,7 +244,7 @@ void tst_QProcess::simpleStart() process.reset(); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting); QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running); QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); @@ -381,10 +381,10 @@ void tst_QProcess::crashTest() QVERIFY(process->waitForFinished(30000)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit); QCOMPARE(process->exitStatus(), QProcess::CrashExit); @@ -392,7 +392,7 @@ void tst_QProcess::crashTest() // delete process; process.reset(); - QCOMPARE(stateSpy.count(), 3); + QCOMPARE(stateSpy.size(), 3); QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting); QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running); QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning); @@ -419,10 +419,10 @@ void tst_QProcess::crashTest2() if (QTestEventLoop::instance().timeout()) QFAIL("Failed to detect crash : operation timed out"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit); QCOMPARE(process.exitStatus(), QProcess::CrashExit); @@ -528,9 +528,9 @@ void tst_QProcess::echoTest2() break; } - QVERIFY(spy0.count() > 0); - QVERIFY(spy1.count() > 0); - QVERIFY(spy2.count() > 0); + QVERIFY(spy0.size() > 0); + QVERIFY(spy1.size() > 0); + QVERIFY(spy2.size() > 0); QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello")); QCOMPARE(process.readAllStandardError(), QByteArray("Hello")); @@ -631,8 +631,8 @@ void tst_QProcess::exitStatus() QFETCH(QStringList, processList); QFETCH(QList<QProcess::ExitStatus>, exitStatus); - QCOMPARE(exitStatus.count(), processList.count()); - for (int i = 0; i < processList.count(); ++i) { + QCOMPARE(exitStatus.size(), processList.size()); + for (int i = 0; i < processList.size(); ++i) { process.start(processList.at(i)); QVERIFY(process.waitForStarted(5000)); QVERIFY(process.waitForFinished(30000)); @@ -685,7 +685,7 @@ void tst_QProcess::readTimeoutAndThenCrash() QVERIFY(process.waitForFinished(5000)); QCOMPARE(process.state(), QProcess::NotRunning); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); } @@ -862,7 +862,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() proc.start("testProcessEcho/testProcessEcho"); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); proc.write("A"); @@ -870,7 +870,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() if (QTestEventLoop::instance().timeout()) QFAIL("Operation timed out"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTestEventLoop::instance().enterLoop(1); QVERIFY(QTestEventLoop::instance().timeout()); @@ -1282,7 +1282,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() QTestEventLoop::instance().enterLoop(30); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); process.disconnect(); QVERIFY(process.waitForFinished(5000)); @@ -1318,7 +1318,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() QTestEventLoop::instance().enterLoop(30); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); process.write("", 1); process.disconnect(); QVERIFY(process.waitForFinished()); @@ -1508,7 +1508,7 @@ void tst_QProcess::failToStart() for (int j = 0; j < 8; ++j) { for (int i = 0; i < attempts; ++i) { - QCOMPARE(errorSpy.count(), j * attempts + i); + QCOMPARE(errorSpy.size(), j * attempts + i); process.start("/blurp"); switch (j) { @@ -1532,12 +1532,12 @@ void tst_QProcess::failToStart() } QCOMPARE(process.error(), QProcess::FailedToStart); - QCOMPARE(errorSpy.count(), j * attempts + i + 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(errorSpy.size(), j * attempts + i + 1); + QCOMPARE(finishedSpy.size(), 0); int it = j * attempts + i + 1; - QCOMPARE(stateSpy.count(), it * 2); + QCOMPARE(stateSpy.size(), it * 2); QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); } @@ -1561,8 +1561,8 @@ void tst_QProcess::failToStartWithWait() process.waitForStarted(); QCOMPARE(process.error(), QProcess::FailedToStart); - QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(errorSpy.size(), i + 1); + QCOMPARE(finishedSpy.size(), 0); } } @@ -1588,8 +1588,8 @@ void tst_QProcess::failToStartWithEventLoop() loop.exec(); QCOMPARE(process.error(), QProcess::FailedToStart); - QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(errorSpy.size(), i + 1); + QCOMPARE(finishedSpy.size(), 0); } } @@ -1621,7 +1621,7 @@ void tst_QProcess::failToStartEmptyArgs() }; QVERIFY(!process.waitForStarted()); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -1860,9 +1860,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); } void tst_QProcess::setStandardInputFile() @@ -2317,7 +2317,7 @@ void tst_QProcess::invalidProgramString() process.start(programString); QCOMPARE(process.error(), QProcess::FailedToStart); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!QProcess::startDetached(programString)); } @@ -2336,8 +2336,8 @@ void tst_QProcess::onlyOneStartedSignal() process.start("testProcessNormal/testProcessNormal"); QVERIFY(process.waitForStarted(5000)); QVERIFY(process.waitForFinished(5000)); - QCOMPARE(spyStarted.count(), 1); - QCOMPARE(spyFinished.count(), 1); + QCOMPARE(spyStarted.size(), 1); + QCOMPARE(spyFinished.size(), 1); spyStarted.clear(); spyFinished.clear(); @@ -2346,8 +2346,8 @@ void tst_QProcess::onlyOneStartedSignal() QVERIFY(process.waitForFinished(5000)); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); - QCOMPARE(spyStarted.count(), 1); - QCOMPARE(spyFinished.count(), 1); + QCOMPARE(spyStarted.size(), 1); + QCOMPARE(spyFinished.size(), 1); } class BlockOnReadStdOut : public QObject @@ -2597,7 +2597,7 @@ void tst_QProcess::startFromCurrentWorkingDir() } QCOMPARE(process.waitForStarted(), success); - QCOMPARE(errorSpy.count(), int(!success)); + QCOMPARE(errorSpy.size(), int(!success)); if (success) { QVERIFY(process.waitForFinished()); } else { diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index 32a12c30bd..9bf8508697 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -130,7 +130,7 @@ void tst_QProcessEnvironment::toStringList() e.insert("FOO", "bar"); QStringList result = e.toStringList(); QVERIFY(!result.isEmpty()); - QCOMPARE(result.length(), 1); + QCOMPARE(result.size(), 1); QCOMPARE(result.at(0), QString("FOO=bar")); e.clear(); @@ -142,7 +142,7 @@ void tst_QProcessEnvironment::toStringList() e.insert("A", "bc"); e.insert("HELLO", "World"); result = e.toStringList(); - QCOMPARE(result.length(), 4); + QCOMPARE(result.size(), 4); // order is not specified, so use contains() QVERIFY(result.contains("FOO=bar")); @@ -159,7 +159,7 @@ void tst_QProcessEnvironment::keys() e.insert("FOO", "bar"); QStringList result = e.keys(); - QCOMPARE(result.length(), 1); + QCOMPARE(result.size(), 1); QCOMPARE(result.at(0), QString("FOO")); e.clear(); @@ -171,7 +171,7 @@ void tst_QProcessEnvironment::keys() e.insert("A", "bc"); e.insert("HELLO", "World"); result = e.keys(); - QCOMPARE(result.length(), 4); + QCOMPARE(result.size(), 4); // order is not specified, so use contains() QVERIFY(result.contains("FOO")); @@ -194,7 +194,7 @@ void tst_QProcessEnvironment::insertEnv() e.insert(e2); QStringList keys = e.keys(); - QCOMPARE(keys.length(), 5); + QCOMPARE(keys.size(), 5); QCOMPARE(e.value("FOO"), QString("bar")); QCOMPARE(e.value("A"), QString("bc")); @@ -244,7 +244,7 @@ void tst_QProcessEnvironment::caseSensitivity() QCOMPARE(e.value("foo"), QString("bar")); QStringList list = e.toStringList(); - QCOMPARE(list.length(), 2); + QCOMPARE(list.size(), 2); QVERIFY(list.contains("foo=bar")); QVERIFY(list.contains("FOO=baz")); #endif diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 19ed36589e..753d3f8b8a 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -550,7 +550,7 @@ void tst_QSettings::ctor() QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3); QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4); QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5); - QCOMPARE(settings1.allKeys().count(), 6); + QCOMPARE(settings1.allKeys().size(), 6); QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), -7); QCOMPARE(settings2.value("alpha/beta/geometry/x").toInt(), 1); @@ -558,7 +558,7 @@ void tst_QSettings::ctor() QCOMPARE(settings2.value("alpha/beta/geometry/width").toInt(), 3); QCOMPARE(settings2.value("alpha/beta/geometry/height").toInt(), 4); QCOMPARE(settings2.value("alpha/gamma/splitter").toInt(), 5); - QCOMPARE(settings2.allKeys().count(), 6); + QCOMPARE(settings2.allKeys().size(), 6); } { @@ -569,7 +569,7 @@ void tst_QSettings::ctor() QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3); QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4); QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5); - QCOMPARE(settings1.allKeys().count(), 6); + QCOMPARE(settings1.allKeys().size(), 6); } { @@ -1731,12 +1731,12 @@ void tst_QSettings::sync() QCOMPARE(settings2.value("moo/beta/geometry/width").toInt(), 3); QCOMPARE(settings2.value("moo/beta/geometry/height").toInt(), 4); QCOMPARE(settings2.value("moo/gamma/splitter").toInt(), 5); - QCOMPARE(settings2.allKeys().count(), 11); + QCOMPARE(settings2.allKeys().size(), 11); // Now, software.org.ini no longer exists, this is same as another app // clearing all settings. settings1.sync(); - QCOMPARE(settings1.allKeys().count(), 0); + QCOMPARE(settings1.allKeys().size(), 0); // Now "some other app" will change software.org.ini QVERIFY(QFile::rename((userConfDir + "other.software.org.ini").toLatin1(), @@ -1754,7 +1754,7 @@ void tst_QSettings::sync() QCOMPARE(settings1.value("moo/beta/geometry/width").toInt(), 3); QCOMPARE(settings1.value("moo/beta/geometry/height").toInt(), 4); QCOMPARE(settings1.value("moo/gamma/splitter").toInt(), 5); - QCOMPARE(settings1.allKeys().count(), 11); + QCOMPARE(settings1.allKeys().size(), 11); } void tst_QSettings::syncNonWriteableDir() @@ -2441,17 +2441,17 @@ void tst_QSettings::testArrays() QCOMPARE(settings1.value("ene").toInt(), 2); QCOMPARE(settings1.value("due").toInt(), 3); QCOMPARE(settings1.value("rike").toInt(), 4); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.setArrayIndex(1); QCOMPARE(settings1.value("ene").toInt(), 5); QCOMPARE(settings1.value("due").toInt(), 6); QCOMPARE(settings1.value("rike").toInt(), 7); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.setArrayIndex(2); QCOMPARE(settings1.value("ene").toInt(), 8); QCOMPARE(settings1.value("due").toInt(), 9); QCOMPARE(settings1.value("rike").toInt(), 10); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.endArray(); settings1.endGroup(); @@ -2501,17 +2501,17 @@ void tst_QSettings::testArrays() QCOMPARE(settings1.value("ene").toInt(), 2); QCOMPARE(settings1.value("due").toInt(), 3); QCOMPARE(settings1.value("rike").toInt(), 4); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.setArrayIndex(1); QCOMPARE(settings1.value("ene").toInt(), 5); QCOMPARE(settings1.value("due").toInt(), 6); QCOMPARE(settings1.value("rike").toInt(), 7); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.setArrayIndex(2); QCOMPARE(settings1.value("ene").toInt(), 8); QCOMPARE(settings1.value("due").toInt(), 9); QCOMPARE(settings1.value("rike").toInt(), 10); - QCOMPARE(settings1.allKeys().count(), 3); + QCOMPARE(settings1.allKeys().size(), 3); settings1.endArray(); settings1.endGroup(); @@ -2683,7 +2683,7 @@ QString escapeWeirdChars(const QString &s) QString result; bool escapeNextDigit = false; - for (int i = 0; i < s.length(); ++i) { + for (int i = 0; i < s.size(); ++i) { QChar c = s.at(i); if (c.unicode() < ' ' || c.unicode() > '~' || (escapeNextDigit && c.unicode() >= '0' && c.unicode() <= 'f')) { diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 2c0500eec9..3b06175aa3 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -147,12 +147,12 @@ void tst_qstandardpaths::testDefaultLocations() QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), expectedConfHome); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), expectedConfHome); const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); - QCOMPARE(confDirs.count(), 2); + QCOMPARE(confDirs.size(), 2); QVERIFY(confDirs.contains(expectedConfHome)); QCOMPARE(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), confDirs); const QStringList genericDataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - QCOMPARE(genericDataDirs.count(), 3); + QCOMPARE(genericDataDirs.size(), 3); const QString expectedDataHome = QDir::homePath() + QString::fromLatin1("/.local/share"); QCOMPARE(genericDataDirs.at(0), expectedDataHome); QCOMPARE(genericDataDirs.at(1), QString::fromLatin1("/usr/local/share")); @@ -260,7 +260,7 @@ void tst_qstandardpaths::testLocateAll() #ifdef Q_XDG_PLATFORM setCustomLocations(); const QStringList appsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "applications", QStandardPaths::LocateDirectory); - QCOMPARE(appsDirs.count(), 0); // they don't exist yet + QCOMPARE(appsDirs.size(), 0); // they don't exist yet const QStringList expectedAppsDirs = QStringList() << m_localAppDir + QLatin1String("/applications") << m_globalAppDir + QLatin1String("/applications"); QDir().mkdir(expectedAppsDirs.at(0)); @@ -301,7 +301,7 @@ void tst_qstandardpaths::testDataLocation() const QString expectedAppDataDir = QDir::homePath() + QString::fromLatin1("/.local/share/Qt/QtTest"); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), expectedAppDataDir); const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation); - QCOMPARE(appDataDirs.count(), 3); + QCOMPARE(appDataDirs.size(), 3); QCOMPARE(appDataDirs.at(0), expectedAppDataDir); QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest")); QCOMPARE(appDataDirs.at(2), QString::fromLatin1("/usr/share/Qt/QtTest")); diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 7761ac5a6a..227c6260d3 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -229,9 +229,9 @@ void tst_QTemporaryDir::fileTemplate() QVERIFY(tempDir.isValid()); QString dirName = QDir(tempDir.path()).dirName(); - if (prefix.length()) { - QCOMPARE(dirName.left(prefix.length()), prefix); - QCOMPARE(dirName.right(suffix.length()), suffix); + if (prefix.size()) { + QCOMPARE(dirName.left(prefix.size()), prefix); + QCOMPARE(dirName.right(suffix.size()), suffix); } } diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index ba37285d5f..556571b346 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -230,11 +230,11 @@ void tst_QTemporaryFile::fileTemplate() QVERIFY2(file.open(), qPrintable(file.errorString())); QString fileName = QFileInfo(file).fileName(); - if (prefix.length()) - QCOMPARE(fileName.left(prefix.length()), prefix); + if (prefix.size()) + QCOMPARE(fileName.left(prefix.size()), prefix); - if (suffix.length()) - QCOMPARE(fileName.right(suffix.length()), suffix); + if (suffix.size()) + QCOMPARE(fileName.right(suffix.size()), suffix); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 48ffa09906..d7f3e45d19 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1090,7 +1090,7 @@ void tst_QUrl::toAndFromStringList() QFETCH(QStringList, strings); const QList<QUrl> urls = QUrl::fromStringList(strings); - QCOMPARE(urls.count(), strings.count()); + QCOMPARE(urls.size(), strings.size()); const QStringList converted = QUrl::toStringList(urls); QCOMPARE(converted, strings); } diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index aa7564f300..d2767f5082 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -721,7 +721,7 @@ void tst_QUrlInternal::encodingRecodeInvalidUtf8() output = QTest::currentDataTag(); if (!qt_urlRecode(output, input, QUrl::FullyEncoded)) output += input; - for (int i = int(strlen(QTest::currentDataTag())); i < output.length(); ++i) { + for (int i = int(strlen(QTest::currentDataTag())); i < output.size(); ++i) { QVERIFY2(output.at(i).unicode() < 0x80 || output.at(i) == QChar::ReplacementCharacter, qPrintable(QString("Character at i == %1 was U+%2").arg(i).arg(output.at(i).unicode(), 4, 16, QLatin1Char('0')))); } diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp index 43a407da9d..15c0474eb0 100644 --- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp +++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp @@ -220,7 +220,7 @@ void tst_QUrlQuery::addRemove() QCOMPARE(query.allQueryItemValues("a"), QStringList() << "b"); QList<QPair<QString, QString> > allItems = query.queryItems(); - QCOMPARE(allItems.count(), 1); + QCOMPARE(allItems.size(), 1); QCOMPARE(allItems.at(0).first, QString("a")); QCOMPARE(allItems.at(0).second, QString("b")); } @@ -238,7 +238,7 @@ void tst_QUrlQuery::addRemove() QCOMPARE(query.allQueryItemValues("c"), QStringList() << "d"); QList<QPair<QString, QString> > allItems = query.queryItems(); - QCOMPARE(allItems.count(), 2); + QCOMPARE(allItems.size(), 2); QVERIFY(allItems.contains(qItem("a", "b"))); QVERIFY(allItems.contains(qItem("c", "d"))); @@ -261,7 +261,7 @@ void tst_QUrlQuery::addRemove() QCOMPARE(query.allQueryItemValues("a"), QStringList() << "b"); QList<QPair<QString, QString> > allItems = query.queryItems(); - QCOMPARE(allItems.count(), 1); + QCOMPARE(allItems.size(), 1); QCOMPARE(allItems.at(0).first, QString("a")); QCOMPARE(allItems.at(0).second, QString("b")); @@ -285,7 +285,7 @@ void tst_QUrlQuery::addRemove() QCOMPARE(query.allQueryItemValues("e"), QStringList() << emptyButNotNull); QList<QPair<QString, QString> > allItems = query.queryItems(); - QCOMPARE(allItems.count(), 2); + QCOMPARE(allItems.size(), 2); QVERIFY(allItems.contains(qItem("a", "b"))); QVERIFY(allItems.contains(qItem("e", emptyButNotNull))); diff --git a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp index e36642974a..9d738941ef 100644 --- a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp +++ b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp @@ -50,7 +50,7 @@ void tst_QUrlUts46::idnaTestV2_data() Q_ASSERT(s.startsWith('[') && s.endsWith(']')); - const auto errors = s.sliced(1, s.length() - 2).split(','); + const auto errors = s.sliced(1, s.size() - 2).split(','); // NOTE: empty string is not in fatalErrors and it's ok return std::all_of(errors.begin(), errors.end(), [](auto &e) { return !fatalErrors.contains(e.trimmed()); }); diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 423cc1bdc8..9b8225a3aa 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -156,8 +156,8 @@ QtTestModel::QtTestModel(const QList<QList<QString> > tbl, QObject *parent) : QAbstractItemModel(parent), wrongIndex(false) { table = tbl; - rCount = tbl.count(); - cCount = tbl.at(0).count(); + rCount = tbl.size(); + cCount = tbl.at(0).size(); } QModelIndex QtTestModel::index(int row, int column, const QModelIndex &parent) const @@ -191,7 +191,7 @@ bool QtTestModel::insertRows(int row, int count, const QModelIndex &parent) QAbstractItemModel::beginInsertRows(parent, row, row + count - 1); int cc = columnCount(parent); table.insert(row, count, QList<QString>(cc)); - rCount = table.count(); + rCount = table.size(); QAbstractItemModel::endInsertRows(); return true; } @@ -202,7 +202,7 @@ bool QtTestModel::insertColumns(int column, int count, const QModelIndex &parent int rc = rowCount(parent); for (int i = 0; i < rc; ++i) table[i].insert(column, 1, ""); - cCount = table.at(0).count(); + cCount = table.at(0).size(); QAbstractItemModel::endInsertColumns(); return true; } @@ -218,7 +218,7 @@ bool QtTestModel::removeRows( int row, int count, const QModelIndex & parent) for (int r = row+count-1; r >= row; --r) table.remove(r); - rCount = table.count(); + rCount = table.size(); QAbstractItemModel::endRemoveRows(); return true; @@ -232,7 +232,7 @@ bool QtTestModel::removeColumns(int column, int count, const QModelIndex & paren for (int r = 0; r < rCount; ++r) table[r].remove(c); - cCount = table.at(0).count(); + cCount = table.at(0).size(); QAbstractItemModel::endRemoveColumns(); return true; @@ -260,7 +260,7 @@ bool QtTestModel::moveRows(const QModelIndex &sourceParent, int src, int cnt, } } - rCount = table.count(); + rCount = table.size(); QAbstractItemModel::endMoveRows(); return true; @@ -290,7 +290,7 @@ bool QtTestModel::moveColumns(const QModelIndex &sourceParent, int src, int cnt, } } - cCount = table.at(0).count(); + cCount = table.at(0).size(); QAbstractItemModel::endMoveColumns(); return true; @@ -418,7 +418,7 @@ void tst_QAbstractItemModel::match() QModelIndex start = model.index(0, 0, QModelIndex()); QVERIFY(start.isValid()); QModelIndexList res = model.match(start, Qt::DisplayRole, QVariant("1"), 3); - QCOMPARE(res.count(), 1); + QCOMPARE(res.size(), 1); QModelIndex idx = model.index(1, 0, QModelIndex()); bool areEqual = (idx == res.first()); QVERIFY(areEqual); @@ -429,42 +429,42 @@ void tst_QAbstractItemModel::match() model.setData(model.index(3, 0, QModelIndex()), "boar", Qt::DisplayRole); res = model.match(start, Qt::DisplayRole, QVariant("dog"), -1, Qt::MatchExactly); - QCOMPARE(res.count(), 1); + QCOMPARE(res.size(), 1); res = model.match(start, Qt::DisplayRole, QVariant("a"), -1, Qt::MatchContains); - QCOMPARE(res.count(), 3); + QCOMPARE(res.size(), 3); res = model.match(start, Qt::DisplayRole, QVariant("b"), -1, Qt::MatchStartsWith); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); res = model.match(start, Qt::DisplayRole, QVariant("t"), -1, Qt::MatchEndsWith); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); res = model.match(start, Qt::DisplayRole, QVariant("*a*"), -1, Qt::MatchWildcard); - QCOMPARE(res.count(), 3); + QCOMPARE(res.size(), 3); res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression | Qt::MatchCaseSensitive); - QCOMPARE(res.count(), 0); + QCOMPARE(res.size(), 0); res = model.match(start, Qt::DisplayRole, QVariant("BOAR"), -1, Qt::MatchFixedString); - QCOMPARE(res.count(), 1); + QCOMPARE(res.size(), 1); res = model.match(start, Qt::DisplayRole, QVariant("bat"), -1, Qt::MatchFixedString | Qt::MatchCaseSensitive); - QCOMPARE(res.count(), 1); + QCOMPARE(res.size(), 1); res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegularExpression | Qt::MatchCaseSensitive); - QCOMPARE(res.count(), 0); + QCOMPARE(res.size(), 0); res = model.match(start, Qt::DisplayRole, QVariant(QRegularExpression(".*O.*")), -1, Qt::MatchRegularExpression); - QCOMPARE(res.count(), 0); + QCOMPARE(res.size(), 0); res = model.match(start, Qt::DisplayRole, QVariant(QRegularExpression(".*O.*", QRegularExpression::CaseInsensitiveOption)), -1, Qt::MatchRegularExpression); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); // Ensure that the case sensitivity is properly ignored when passing a // QRegularExpression object. @@ -474,7 +474,7 @@ void tst_QAbstractItemModel::match() QRegularExpression::CaseInsensitiveOption)), -1, Qt::MatchRegularExpression | Qt::MatchCaseSensitive); - QCOMPARE(res.count(), 2); + QCOMPARE(res.size(), 2); } typedef QPair<int, int> Position; @@ -757,7 +757,7 @@ void tst_QAbstractItemModel::dropMimeData() // get the mimeData from the "selected" indexes QModelIndexList selectedIndexes; - for (int i = 0; i < selection.count(); ++i) + for (int i = 0; i < selection.size(); ++i) selectedIndexes << src.index(selection.at(i).first, selection.at(i).second, QModelIndex()); QMimeData *md = src.mimeData(selectedIndexes); // do the drop @@ -828,8 +828,8 @@ void tst_QAbstractItemModel::removeRows() QVERIFY(rowsRemovedSpy.isValid()); QCOMPARE(model.removeRows(6, 4), true); - QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1); - QCOMPARE(rowsRemovedSpy.count(), 1); + QCOMPARE(rowsAboutToBeRemovedSpy.size(), 1); + QCOMPARE(rowsRemovedSpy.size(), 1); } void tst_QAbstractItemModel::removeColumns() @@ -843,8 +843,8 @@ void tst_QAbstractItemModel::removeColumns() QVERIFY(columnsRemovedSpy.isValid()); QCOMPARE(model.removeColumns(6, 4), true); - QCOMPARE(columnsAboutToBeRemovedSpy.count(), 1); - QCOMPARE(columnsRemovedSpy.count(), 1); + QCOMPARE(columnsAboutToBeRemovedSpy.size(), 1); + QCOMPARE(columnsRemovedSpy.size(), 1); } void tst_QAbstractItemModel::insertRows() @@ -858,8 +858,8 @@ void tst_QAbstractItemModel::insertRows() QVERIFY(rowsInsertedSpy.isValid()); QCOMPARE(model.insertRows(6, 4), true); - QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1); - QCOMPARE(rowsInsertedSpy.count(), 1); + QCOMPARE(rowsAboutToBeInsertedSpy.size(), 1); + QCOMPARE(rowsInsertedSpy.size(), 1); } void tst_QAbstractItemModel::insertColumns() @@ -873,8 +873,8 @@ void tst_QAbstractItemModel::insertColumns() QVERIFY(columnsInsertedSpy.isValid()); QCOMPARE(model.insertColumns(6, 4), true); - QCOMPARE(columnsAboutToBeInsertedSpy.count(), 1); - QCOMPARE(columnsInsertedSpy.count(), 1); + QCOMPARE(columnsAboutToBeInsertedSpy.size(), 1); + QCOMPARE(columnsInsertedSpy.size(), 1); } void tst_QAbstractItemModel::moveRows() @@ -888,8 +888,8 @@ void tst_QAbstractItemModel::moveRows() QVERIFY(rowsMovedSpy.isValid()); QCOMPARE(model.moveRows(QModelIndex(), 6, 4, QModelIndex(), 1), true); - QCOMPARE(rowsAboutToBeMovedSpy.count(), 1); - QCOMPARE(rowsMovedSpy.count(), 1); + QCOMPARE(rowsAboutToBeMovedSpy.size(), 1); + QCOMPARE(rowsMovedSpy.size(), 1); } void tst_QAbstractItemModel::moveColumns() @@ -903,12 +903,12 @@ void tst_QAbstractItemModel::moveColumns() QVERIFY(columnsMovedSpy.isValid()); QCOMPARE(model.moveColumns(QModelIndex(), 6, 4, QModelIndex(), 1), true); - QCOMPARE(columnsAboutToBeMovedSpy.count(), 1); - QCOMPARE(columnsMovedSpy.count(), 1); + QCOMPARE(columnsAboutToBeMovedSpy.size(), 1); + QCOMPARE(columnsMovedSpy.size(), 1); QCOMPARE(model.moveColumn(QModelIndex(), 4, QModelIndex(), 1), true); - QCOMPARE(columnsAboutToBeMovedSpy.count(), 2); - QCOMPARE(columnsMovedSpy.count(), 2); + QCOMPARE(columnsAboutToBeMovedSpy.size(), 2); + QCOMPARE(columnsMovedSpy.size(), 2); } void tst_QAbstractItemModel::reset() @@ -918,7 +918,7 @@ void tst_QAbstractItemModel::reset() QSignalSpy resetSpy(&model, &QtTestModel::modelReset); QVERIFY(resetSpy.isValid()); model.reset(); - QCOMPARE(resetSpy.count(), 1); + QCOMPARE(resetSpy.size(), 1); } void tst_QAbstractItemModel::complexChangesWithPersistent() diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp index b8283709e2..3bea468e5b 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -225,7 +225,7 @@ void tst_QAbstractProxyModel::headerDataInBounds() QCOMPARE(proxy.rowCount(), 1); QCOMPARE(proxy.columnCount(), 5); - QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy.size(), 1); QCOMPARE(headerDataChangedSpy[0][0].value<Qt::Orientation>(), Qt::Horizontal); QCOMPARE(headerDataChangedSpy[0][1].value<int>(), 0); QCOMPARE(headerDataChangedSpy[0][2].value<int>(), 4); @@ -244,7 +244,7 @@ void tst_QAbstractProxyModel::headerDataInBounds() }); QCOMPARE(proxy.rowCount(), 2); QCOMPARE(proxy.columnCount(), 5); - QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy.size(), 1); for (int i = 0; i < proxy.columnCount(); ++i) { QString expected = QString("Col%1").arg(proxy.columnCount() - i); @@ -255,7 +255,7 @@ void tst_QAbstractProxyModel::headerDataInBounds() QCOMPARE(proxy.rowCount(), 1); QCOMPARE(proxy.columnCount(), 5); - QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy.size(), 1); for (int i = 0; i < proxy.columnCount(); ++i) { QString expected = QString("Col%1").arg(proxy.columnCount() - i); @@ -266,7 +266,7 @@ void tst_QAbstractProxyModel::headerDataInBounds() QCOMPARE(proxy.rowCount(), 0); QCOMPARE(proxy.columnCount(), 5); - QCOMPARE(headerDataChangedSpy.count(), 2); + QCOMPARE(headerDataChangedSpy.size(), 2); QCOMPARE(headerDataChangedSpy[1][0].value<Qt::Orientation>(), Qt::Horizontal); QCOMPARE(headerDataChangedSpy[1][1].value<int>(), 0); QCOMPARE(headerDataChangedSpy[1][2].value<int>(), 4); @@ -291,7 +291,7 @@ void tst_QAbstractProxyModel::itemData() QFETCH(QModelIndex, index); QFETCH(int, count); SubQAbstractProxyModel model; - QCOMPARE(model.itemData(index).count(), count); + QCOMPARE(model.itemData(index).size(), count); } void tst_QAbstractProxyModel::mapFromSource_data() diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index 9990aaf2ed..45d734d9e8 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -46,9 +46,9 @@ static QString rowSpyToText(const QSignalSpy &spy) if (!spy.isValid()) return QStringLiteral("THE SIGNALSPY IS INVALID!"); QString str; - for (int i = 0; i < spy.count(); ++i) { + for (int i = 0; i < spy.size(); ++i) { str += spy.at(i).at(1).toString() + QLatin1Char(',') + spy.at(i).at(2).toString(); - if (i + 1 < spy.count()) + if (i + 1 < spy.size()) str += QLatin1Char(';'); } return str; @@ -149,8 +149,8 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateThenRemoveTwoEmptyModelsCo // Then the proxy should still be empty (and no signals emitted) QCOMPARE(pm.rowCount(), 0); QCOMPARE(pm.columnCount(), 0); - QCOMPARE(rowATBISpy.count(), 0); - QCOMPARE(rowInsertedSpy.count(), 0); + QCOMPARE(rowATBISpy.size(), 0); + QCOMPARE(rowInsertedSpy.size(), 0); // When removing the empty models pm.removeSourceModel(&i1); @@ -159,8 +159,8 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateThenRemoveTwoEmptyModelsCo // Then the proxy should still be empty (and no signals emitted) QCOMPARE(pm.rowCount(), 0); QCOMPARE(pm.columnCount(), 0); - QCOMPARE(rowATBRSpy.count(), 0); - QCOMPARE(rowRemovedSpy.count(), 0); + QCOMPARE(rowATBRSpy.size(), 0); + QCOMPARE(rowRemovedSpy.size(), 0); } void tst_QConcatenateTablesProxyModel::shouldAggregateTwoEmptyModelsWhichThenGetFilled() @@ -205,14 +205,14 @@ void tst_QConcatenateTablesProxyModel::shouldHandleDataChanged() mod.item(0, 0)->setData("a", Qt::EditRole); // Then the change should be notified to the proxy - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC")); // Same test with the other model mod2.item(0, 2)->setData("f", Qt::EditRole); - QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.size(), 2); QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf")); } @@ -230,14 +230,14 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetData() pm.setData(pm.index(0, 0), "a"); // Then the change should be notified to the proxy - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC")); // Same test with the other model pm.setData(pm.index(1, 2), "f"); - QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.size(), 2); QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf")); } @@ -256,7 +256,7 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetItemData() std::make_pair<int, QVariant>(Qt::UserRole, 88) }); // Then the change should be notified to the proxy - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("XBC")); QCOMPARE(pm.index(0, 0).data(Qt::UserRole).toInt(), 88); @@ -265,7 +265,7 @@ void tst_QConcatenateTablesProxyModel::shouldHandleSetItemData() pm.setItemData(pm.index(1, 2), QMap<int, QVariant>{ std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("Y")), std::make_pair<int, QVariant>(Qt::UserRole, 89) }); - QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.size(), 2); QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEY")); QCOMPARE(pm.index(1, 2).data(Qt::UserRole).toInt(), 89); @@ -302,10 +302,10 @@ void tst_QConcatenateTablesProxyModel::shouldHandleRowInsertionAndRemoval() mod2.removeRow(0); // Then the proxy should notify its users and show changes - QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 1); QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); - QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.size(), 1); QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); QCOMPARE(pm.rowCount(), 2); @@ -318,10 +318,10 @@ void tst_QConcatenateTablesProxyModel::shouldHandleRowInsertionAndRemoval() mod2.removeRow(0); // Then the proxy should notify its users and show changes - QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 1); QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); - QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.size(), 1); QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); QCOMPARE(pm.rowCount(), 1); @@ -357,10 +357,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode pm.removeSourceModel(&mod3); // Then the proxy should notify its users about the row removed - QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 1); QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 2); QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 3); - QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.size(), 1); QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 2); QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 3); QCOMPARE(pm.rowCount(), 2); @@ -371,10 +371,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode rowATBRSpy.clear(); rowRemovedSpy.clear(); pm.removeSourceModel(&mod2); - QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 1); QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); - QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.size(), 1); QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); QCOMPARE(pm.rowCount(), 1); @@ -384,10 +384,10 @@ void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveMode rowATBRSpy.clear(); rowRemovedSpy.clear(); pm.removeSourceModel(&mod); - QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 1); QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 0); QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 0); - QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.size(), 1); QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 0); QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 0); QCOMPARE(pm.rowCount(), 0); @@ -423,11 +423,11 @@ void tst_QConcatenateTablesProxyModel::shouldUseSmallestColumnCount() // Test setData in an ignored column (QTBUG-91253) QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); mod.setData(mod.index(0, 1), "b"); - QCOMPARE(dataChangedSpy.count(), 0); + QCOMPARE(dataChangedSpy.size(), 0); // Test dataChanged across all columns, some visible, some ignored mod.dataChanged(mod.index(0, 0), mod.index(0, 2)); - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); QCOMPARE(dataChangedSpy.at(0).at(1).toModelIndex(), pm.index(0, 0)); } @@ -517,8 +517,8 @@ void tst_QConcatenateTablesProxyModel::shouldPropagateLayoutChanged() QItemSelectionModel selection(&pm); selection.select(pm.index(1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); const QModelIndexList lst = selection.selectedIndexes(); - QCOMPARE(lst.count(), 3); - for (int col = 0; col < lst.count(); ++col) { + QCOMPARE(lst.size(), 3); + for (int col = 0; col < lst.size(); ++col) { QCOMPARE(lst.at(col).row(), 1); QCOMPARE(lst.at(col).column(), col); } @@ -533,13 +533,13 @@ void tst_QConcatenateTablesProxyModel::shouldPropagateLayoutChanged() QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("123")); - QCOMPARE(layoutATBCSpy.count(), 1); - QCOMPARE(layoutChangedSpy.count(), 1); + QCOMPARE(layoutATBCSpy.size(), 1); + QCOMPARE(layoutChangedSpy.size(), 1); // And the selection should be updated accordingly (it became row 2) const QModelIndexList lstAfter = selection.selectedIndexes(); - QCOMPARE(lstAfter.count(), 3); - for (int col = 0; col < lstAfter.count(); ++col) { + QCOMPARE(lstAfter.size(), 3); + for (int col = 0; col < lstAfter.size(); ++col) { QCOMPARE(lstAfter.at(col).row(), 2); QCOMPARE(lstAfter.at(col).column(), col); } @@ -574,14 +574,14 @@ void tst_QConcatenateTablesProxyModel::shouldReactToModelReset() // Then the proxy should emit the reset signals, and show the new data QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); - QCOMPARE(rowATBRSpy.count(), 0); - QCOMPARE(rowRemovedSpy.count(), 0); - QCOMPARE(rowATBISpy.count(), 0); - QCOMPARE(rowInsertedSpy.count(), 0); - QCOMPARE(colATBRSpy.count(), 0); - QCOMPARE(colRemovedSpy.count(), 0); - QCOMPARE(modelATBResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(rowATBRSpy.size(), 0); + QCOMPARE(rowRemovedSpy.size(), 0); + QCOMPARE(rowATBISpy.size(), 0); + QCOMPARE(rowInsertedSpy.size(), 0); + QCOMPARE(colATBRSpy.size(), 0); + QCOMPARE(colRemovedSpy.size(), 0); + QCOMPARE(modelATBResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); } void tst_QConcatenateTablesProxyModel::shouldUpdateColumnsOnModelReset() @@ -616,14 +616,14 @@ void tst_QConcatenateTablesProxyModel::shouldUpdateColumnsOnModelReset() qsfpm.setSourceModel(&mod2Columns); // Then the proxy should reset, and show the new data - QCOMPARE(modelATBResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); - QCOMPARE(rowATBRSpy.count(), 0); - QCOMPARE(rowRemovedSpy.count(), 0); - QCOMPARE(rowATBISpy.count(), 0); - QCOMPARE(rowInsertedSpy.count(), 0); - QCOMPARE(colATBRSpy.count(), 0); - QCOMPARE(colRemovedSpy.count(), 0); + QCOMPARE(modelATBResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); + QCOMPARE(rowATBRSpy.size(), 0); + QCOMPARE(rowRemovedSpy.size(), 0); + QCOMPARE(rowATBISpy.size(), 0); + QCOMPARE(rowInsertedSpy.size(), 0); + QCOMPARE(colATBRSpy.size(), 0); + QCOMPARE(colRemovedSpy.size(), 0); QCOMPARE(pm.rowCount(), 2); QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("WX")); diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 1ce10c46aa..e5470fc3d1 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -587,7 +587,7 @@ void tst_QItemModel::setData() QVERIFY(currentModel); QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged); QVERIFY(spy.isValid()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QFETCH(bool, isEmpty); if (isEmpty) @@ -611,7 +611,7 @@ void tst_QItemModel::setData() // Changing the text shouldn't change the layout, parent, pointer etc. QModelIndex changedIndex = currentModel->index(0, 0, topIndex); QCOMPARE(changedIndex, index); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QItemModel::setHeaderData_data() @@ -661,7 +661,7 @@ void tst_QItemModel::setHeaderData() ++signalCount; } } - QCOMPARE(spy.count(), signalCount); + QCOMPARE(spy.size(), signalCount); } void tst_QItemModel::sort_data() @@ -692,7 +692,7 @@ void tst_QItemModel::sort() for (int i=-1; i < 10; ++i){ currentModel->sort(i); if (index != currentModel->index(0, 0, topIndex)){ - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); index = currentModel->index(0, 0, topIndex); spy.clear(); } @@ -858,7 +858,7 @@ void tst_QItemModel::remove() if (shouldSucceed && dyingIndex.isValid()) QCOMPARE(dyingIndex.row(), start + 1); - if (rowsAboutToBeRemovedSpy.count() > 0){ + if (rowsAboutToBeRemovedSpy.size() > 0){ QList<QVariant> arguments = rowsAboutToBeRemovedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -868,7 +868,7 @@ void tst_QItemModel::remove() QVERIFY(parentOfRemoved == parent); } - if (rowsRemovedSpy.count() > 0){ + if (rowsRemovedSpy.size() > 0){ QList<QVariant> arguments = rowsRemovedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -879,26 +879,26 @@ void tst_QItemModel::remove() } // Only the row signals should have been emitted - if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >=1 ){ - QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0); - QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0); - QCOMPARE(columnsRemovedSpy.count(), 0); - QCOMPARE(rowsRemovedSpy.count(), 0); + if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >=1 ){ + QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0); + QCOMPARE(rowsAboutToBeRemovedSpy.size(), 0); + QCOMPARE(columnsRemovedSpy.size(), 0); + QCOMPARE(rowsRemovedSpy.size(), 0); } else { - QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0); - QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals); - QCOMPARE(columnsRemovedSpy.count(), 0); - QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals); + QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0); + QCOMPARE(rowsAboutToBeRemovedSpy.size(), numberOfRowsAboutToBeRemovedSignals); + QCOMPARE(columnsRemovedSpy.size(), 0); + QCOMPARE(rowsRemovedSpy.size(), numberOfRowsRemovedSignals); } // The row count should only change *after* rowsAboutToBeRemoved has been emitted if (shouldSucceed) { - if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){ + if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0){ QCOMPARE(afterAboutToRemoveRowCount, beforeRemoveRowCount); QCOMPARE(afterRemoveRowCount, beforeRemoveRowCount-count-(numberOfRowsRemovedSignals-1)); } - if (modelResetSpy.count() == 0 ) + if (modelResetSpy.size() == 0 ) QCOMPARE(currentModel->rowCount(parentOfRemoved), beforeRemoveRowCount-count-(numberOfRowsRemovedSignals-1)); } else { @@ -913,7 +913,7 @@ void tst_QItemModel::remove() disconnect(currentModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(slot_rowsRemoved(QModelIndex))); modelResetSpy.clear(); - QCOMPARE(modelResetSpy.count(), 0); + QCOMPARE(modelResetSpy.size(), 0); // // Test remove column @@ -928,26 +928,26 @@ void tst_QItemModel::remove() if (currentModel->removeColumns(start, count, parentOfRemoved)) { currentModel->submit(); // Didn't reset the rows, so they should still be at the same value - if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1){ - QCOMPARE(columnsAboutToBeRemovedSpy.count(), 0); + if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1){ + QCOMPARE(columnsAboutToBeRemovedSpy.size(), 0); //QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals); - QCOMPARE(columnsRemovedSpy.count(), 0); + QCOMPARE(columnsRemovedSpy.size(), 0); //QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals); } else { - QCOMPARE(columnsAboutToBeRemovedSpy.count(), numberOfColumnsAboutToBeRemovedSignals); - QCOMPARE(rowsAboutToBeRemovedSpy.count(), numberOfRowsAboutToBeRemovedSignals); - QCOMPARE(columnsRemovedSpy.count(), numberOfColumnsRemovedSignals); - QCOMPARE(rowsRemovedSpy.count(), numberOfRowsRemovedSignals); + QCOMPARE(columnsAboutToBeRemovedSpy.size(), numberOfColumnsAboutToBeRemovedSignals); + QCOMPARE(rowsAboutToBeRemovedSpy.size(), numberOfRowsAboutToBeRemovedSignals); + QCOMPARE(columnsRemovedSpy.size(), numberOfColumnsRemovedSignals); + QCOMPARE(rowsRemovedSpy.size(), numberOfRowsRemovedSignals); } // The column count should only change *after* rowsAboutToBeRemoved has been emitted if (shouldSucceed) { - if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0){ + if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0){ QCOMPARE(afterAboutToRemoveColumnCount, beforeRemoveColumnCount); QCOMPARE(afterRemoveColumnCount, beforeRemoveColumnCount-count-(numberOfColumnsRemovedSignals-1)); } - if (modelResetSpy.count() == 0) + if (modelResetSpy.size() == 0) QCOMPARE(currentModel->columnCount(parentOfRemoved), beforeRemoveColumnCount-count-(numberOfColumnsRemovedSignals-1)); } else @@ -958,7 +958,7 @@ void tst_QItemModel::remove() disconnect(currentModel, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(slot_columnsRemoved(QModelIndex))); - if (columnsAboutToBeRemovedSpy.count() > 0){ + if (columnsAboutToBeRemovedSpy.size() > 0){ QList<QVariant> arguments = columnsAboutToBeRemovedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -968,7 +968,7 @@ void tst_QItemModel::remove() QVERIFY(parentOfRemoved == parent); } - if (columnsRemovedSpy.count() > 0){ + if (columnsRemovedSpy.size() > 0){ QList<QVariant> arguments = columnsRemovedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -1197,7 +1197,7 @@ void tst_QItemModel::insert() QCOMPARE(currentModel->insertRows(start, count, parentOfInserted), shouldSucceed); currentModel->submit(); - if (rowsAboutToBeInsertedSpy.count() > 0){ + if (rowsAboutToBeInsertedSpy.size() > 0){ QList<QVariant> arguments = rowsAboutToBeInsertedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -1207,7 +1207,7 @@ void tst_QItemModel::insert() QVERIFY(parentOfInserted == parent); } - if (rowsInsertedSpy.count() > 0){ + if (rowsInsertedSpy.size() > 0){ QList<QVariant> arguments = rowsInsertedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -1218,25 +1218,25 @@ void tst_QItemModel::insert() } // Only the row signals should have been emitted - if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1) { - QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0); - QCOMPARE(rowsAboutToBeInsertedSpy.count(), 0); - QCOMPARE(columnsInsertedSpy.count(), 0); - QCOMPARE(rowsInsertedSpy.count(), 0); + if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1) { + QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0); + QCOMPARE(rowsAboutToBeInsertedSpy.size(), 0); + QCOMPARE(columnsInsertedSpy.size(), 0); + QCOMPARE(rowsInsertedSpy.size(), 0); } else { - QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0); - QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals); - QCOMPARE(columnsInsertedSpy.count(), 0); - QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals); + QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0); + QCOMPARE(rowsAboutToBeInsertedSpy.size(), numberOfRowsAboutToBeInsertedSignals); + QCOMPARE(columnsInsertedSpy.size(), 0); + QCOMPARE(rowsInsertedSpy.size(), numberOfRowsInsertedSignals); } // The row count should only change *after* rowsAboutToBeInserted has been emitted if (shouldSucceed) { - if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) { + if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0) { QCOMPARE(afterAboutToInsertRowCount, beforeInsertRowCount); QCOMPARE(afterInsertRowCount, beforeInsertRowCount+count+(numberOfRowsInsertedSignals-1)); } - if (modelResetSpy.count() == 0) + if (modelResetSpy.size() == 0) QCOMPARE(currentModel->rowCount(parentOfInserted), beforeInsertRowCount+count+(numberOfRowsInsertedSignals-1)); } else { @@ -1264,27 +1264,27 @@ void tst_QItemModel::insert() // Some models don't let you insert the column, only row if (currentModel->insertColumns(start, count, parentOfInserted)) { currentModel->submit(); - if (modelResetSpy.count() >= 1 || modelLayoutChangedSpy.count() >= 1) { + if (modelResetSpy.size() >= 1 || modelLayoutChangedSpy.size() >= 1) { // Didn't reset the rows, so they should still be at the same value - QCOMPARE(columnsAboutToBeInsertedSpy.count(), 0); + QCOMPARE(columnsAboutToBeInsertedSpy.size(), 0); //QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals); - QCOMPARE(columnsInsertedSpy.count(), 0); + QCOMPARE(columnsInsertedSpy.size(), 0); //QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals); } else { // Didn't reset the rows, so they should still be at the same value - QCOMPARE(columnsAboutToBeInsertedSpy.count(), numberOfColumnsAboutToBeInsertedSignals); - QCOMPARE(rowsAboutToBeInsertedSpy.count(), numberOfRowsAboutToBeInsertedSignals); - QCOMPARE(columnsInsertedSpy.count(), numberOfColumnsInsertedSignals); - QCOMPARE(rowsInsertedSpy.count(), numberOfRowsInsertedSignals); + QCOMPARE(columnsAboutToBeInsertedSpy.size(), numberOfColumnsAboutToBeInsertedSignals); + QCOMPARE(rowsAboutToBeInsertedSpy.size(), numberOfRowsAboutToBeInsertedSignals); + QCOMPARE(columnsInsertedSpy.size(), numberOfColumnsInsertedSignals); + QCOMPARE(rowsInsertedSpy.size(), numberOfRowsInsertedSignals); } // The column count should only change *after* rowsAboutToBeInserted has been emitted if (shouldSucceed) { - if (modelResetSpy.count() == 0 && modelLayoutChangedSpy.count() == 0) { + if (modelResetSpy.size() == 0 && modelLayoutChangedSpy.size() == 0) { QCOMPARE(afterAboutToInsertColumnCount, beforeInsertColumnCount); QCOMPARE(afterInsertColumnCount, beforeInsertColumnCount+count+(numberOfColumnsInsertedSignals-1)); } - if (modelResetSpy.count() == 0) + if (modelResetSpy.size() == 0) QCOMPARE(currentModel->columnCount(parentOfInserted), beforeInsertColumnCount+count+(numberOfColumnsInsertedSignals-1)); } else @@ -1295,7 +1295,7 @@ void tst_QItemModel::insert() disconnect(currentModel, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(slot_columnsInserted(QModelIndex))); - if (columnsAboutToBeInsertedSpy.count() > 0){ + if (columnsAboutToBeInsertedSpy.size() > 0){ QList<QVariant> arguments = columnsAboutToBeInsertedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); @@ -1305,7 +1305,7 @@ void tst_QItemModel::insert() QVERIFY(parentOfInserted == parent); } - if (columnsInsertedSpy.count() > 0){ + if (columnsInsertedSpy.size() > 0){ QList<QVariant> arguments = columnsInsertedSpy.at(0); QModelIndex parent = (qvariant_cast<QModelIndex>(arguments.at(0))); int first = arguments.at(1).toInt(); diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 1a9875a1eb..2d09b01c26 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -141,8 +141,8 @@ QDataStream &operator>>(QDataStream &s, QModelIndex &output) QDataStream &operator<<(QDataStream &s, const QModelIndexList &input) { - s << input.count(); - for (int i=0; i<input.count(); ++i) + s << input.size(); + for (int i=0; i<input.size(); ++i) s << input.at(i); return s; } @@ -278,7 +278,7 @@ void tst_QItemSelectionModel::clear() QFETCH(IntList, commandList); // do selections - for (int i=0; i<indexList.count(); ++i) { + for (int i=0; i<indexList.size(); ++i) { selection->select(indexList.at(i), (QItemSelectionModel::SelectionFlags)commandList.at(i)); } // test that we have selected items @@ -292,7 +292,7 @@ void tst_QItemSelectionModel::clearAndSelect() { // populate selectionmodel selection->select(model->index(1, 1, QModelIndex()), QItemSelectionModel::Select); - QCOMPARE(selection->selectedIndexes().count(), 1); + QCOMPARE(selection->selectedIndexes().size(), 1); QVERIFY(selection->hasSelection()); // ClearAndSelect with empty selection @@ -310,26 +310,26 @@ void tst_QItemSelectionModel::toggleSelection() //and hasSelection returns the correct value selection->clearSelection(); - QCOMPARE(selection->selectedIndexes().count(), 0); + QCOMPARE(selection->selectedIndexes().size(), 0); QVERIFY(selection->hasSelection()==false); QModelIndex index=model->index(1, 1, QModelIndex()); // populate selectionmodel selection->select(index, QItemSelectionModel::Toggle); - QCOMPARE(selection->selectedIndexes().count(), 1); + QCOMPARE(selection->selectedIndexes().size(), 1); QVERIFY(selection->hasSelection()==true); selection->select(index, QItemSelectionModel::Toggle); - QCOMPARE(selection->selectedIndexes().count(), 0); + QCOMPARE(selection->selectedIndexes().size(), 0); QVERIFY(selection->hasSelection()==false); // populate selectionmodel with rows selection->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows); - QCOMPARE(selection->selectedIndexes().count(), model->columnCount()); + QCOMPARE(selection->selectedIndexes().size(), model->columnCount()); QVERIFY(selection->hasSelection()==true); selection->select(index, QItemSelectionModel::Toggle | QItemSelectionModel::Rows); - QCOMPARE(selection->selectedIndexes().count(), 0); + QCOMPARE(selection->selectedIndexes().size(), 0); QVERIFY(selection->hasSelection()==false); } @@ -1221,7 +1221,7 @@ void tst_QItemSelectionModel::select() int lastCommand = 0; // do selections - for (int i = 0; i<commandList.count(); ++i) { + for (int i = 0; i<commandList.size(); ++i) { if (useRanges) { selection->select(QItemSelection(indexList.at(2*i), indexList.at(2*i+1)), (QItemSelectionModel::SelectionFlags)commandList.at(i)); @@ -1238,13 +1238,13 @@ void tst_QItemSelectionModel::select() QVERIFY(selection->hasSelection()!=selectedList.isEmpty()); // test that the number of indices are as expected - QVERIFY2(selectedList.count() == expectedList.count(), + QVERIFY2(selectedList.size() == expectedList.size(), QString("expected indices: %1 actual indices: %2") - .arg(expectedList.count()) - .arg(selectedList.count()).toLatin1()); + .arg(expectedList.size()) + .arg(selectedList.size()).toLatin1()); // test existence of each index - for (int i=0; i<expectedList.count(); ++i) { + for (int i=0; i<expectedList.size(); ++i) { QVERIFY2(selectedList.contains(expectedList.at(i)), QString("expected index(%1, %2) not found in selectedIndexes()") .arg(expectedList.at(i).row()) @@ -1252,7 +1252,7 @@ void tst_QItemSelectionModel::select() } // test that isSelected agrees - for (int i=0; i<indexList.count(); ++i) { + for (int i=0; i<indexList.size(); ++i) { QModelIndex idx = indexList.at(i); QVERIFY2(selection->isSelected(idx) == selectedList.contains(idx), QString("isSelected(index: %1, %2) does not match selectedIndexes()") @@ -1263,7 +1263,7 @@ void tst_QItemSelectionModel::select() //for now we assume Rows/Columns flag is the same for all commands, therefore we just check lastCommand // test that isRowSelected agrees if (lastCommand & QItemSelectionModel::Rows) { - for (int i=0; i<selectedList.count(); ++i) + for (int i=0; i<selectedList.size(); ++i) QVERIFY2(selection->isRowSelected(selectedList.at(i).row(), model->parent(selectedList.at(i))), QString("isRowSelected(row: %1) does not match selectedIndexes()") @@ -1272,7 +1272,7 @@ void tst_QItemSelectionModel::select() // test that isColumnSelected agrees if (lastCommand & QItemSelectionModel::Columns) { - for (int i=0; i<selectedList.count(); ++i) + for (int i=0; i<selectedList.size(); ++i) QVERIFY2(selection->isColumnSelected(selectedList.at(i).column(), model->parent(selectedList.at(i))), QString("isColumnSelected(column: %1) does not match selectedIndexes()") @@ -1456,8 +1456,8 @@ void tst_QItemSelectionModel::persistentselections() QCOMPARE(model->columnCount(QModelIndex()), 5); // do selections - for (int i=0; i<commandList.count(); ++i) { - if (indexList.count() == commandList.count()) { + for (int i=0; i<commandList.size(); ++i) { + if (indexList.size() == commandList.size()) { QModelIndex index = model->index(indexList.at(i).first, indexList.at(i).second, QModelIndex()); @@ -1478,18 +1478,18 @@ void tst_QItemSelectionModel::persistentselections() QVERIFY(selection->hasSelection()); // insert/delete row and/or columns - if (insertRows.count() > 1) + if (insertRows.size() > 1) model->insertRows(insertRows.at(0), insertRows.at(1), QModelIndex()); - if (insertColumns.count() > 1) + if (insertColumns.size() > 1) model->insertColumns(insertColumns.at(0), insertColumns.at(1), QModelIndex()); - if (deleteRows.count() > 1) + if (deleteRows.size() > 1) model->removeRows(deleteRows.at(0), deleteRows.at(1), QModelIndex()); - if (deleteColumns.count() > 1) + if (deleteColumns.size() > 1) model->removeColumns(deleteColumns.at(0), deleteColumns.at(1), QModelIndex()); // check that the selected items are the correct number and indexes QModelIndexList selectedList = selection->selectedIndexes(); - QCOMPARE(selectedList.count(), expectedList.count()); + QCOMPARE(selectedList.size(), expectedList.size()); for (const auto &pair : expectedList) { QModelIndex index = model->index(pair.first, pair.second, QModelIndex()); QVERIFY(selectedList.contains(index)); @@ -1515,7 +1515,7 @@ void tst_QItemSelectionModel::resetModel() selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); model.reset(); @@ -1524,8 +1524,8 @@ void tst_QItemSelectionModel::resetModel() selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).count(), 2); + QCOMPARE(spy.size(), 2); + QCOMPARE(spy.at(1).size(), 2); // make sure we don't get an "old selection" QCOMPARE(spy.at(1).at(1).userType(), qMetaTypeId<QItemSelection>()); QVERIFY(qvariant_cast<QItemSelection>(spy.at(1).at(1)).isEmpty()); @@ -1580,14 +1580,14 @@ void tst_QItemSelectionModel::removeRows() QModelIndex br = model.index(selectBottom, selectRight); selections.select(QItemSelection(tl, br), QItemSelectionModel::ClearAndSelect); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(selections.isSelected(tl)); QVERIFY(selections.isSelected(br)); QVERIFY(selections.hasSelection()); model.removeRows(removeTop, removeBottom - removeTop + 1); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); tl = model.index(expectedTop, expectedLeft); br = model.index(expectedBottom, expectedRight); QVERIFY(selections.isSelected(tl)); @@ -1643,14 +1643,14 @@ void tst_QItemSelectionModel::removeColumns() QModelIndex br = model.index(selectBottom, selectRight); selections.select(QItemSelection(tl, br), QItemSelectionModel::ClearAndSelect); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(selections.isSelected(tl)); QVERIFY(selections.isSelected(br)); QVERIFY(selections.hasSelection()); model.removeColumns(removeLeft, removeRight - removeLeft + 1); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); tl = model.index(expectedTop, expectedLeft); br = model.index(expectedBottom, expectedRight); QVERIFY(selections.isSelected(tl)); @@ -1721,7 +1721,7 @@ void tst_QItemSelectionModel::modelLayoutChanged() QFETCH(int, sortColumn); QFETCH(IntPairPairList, expectedSelectedRanges); - MyStandardItemModel model(items.at(0).count(), items.count()); + MyStandardItemModel model(items.at(0).size(), items.size()); // initialize model data for (int i = 0; i < model.rowCount(); ++i) { for (int j = 0; j < model.columnCount(); ++j) { @@ -1746,10 +1746,10 @@ void tst_QItemSelectionModel::modelLayoutChanged() // verify that selection is as expected QItemSelection selection = selectionModel.selection(); - QCOMPARE(selection.count(), expectedSelectedRanges.count()); + QCOMPARE(selection.size(), expectedSelectedRanges.size()); QCOMPARE(selectionModel.hasSelection(), !expectedSelectedRanges.isEmpty()); - for (int i = 0; i < expectedSelectedRanges.count(); ++i) { + for (int i = 0; i < expectedSelectedRanges.size(); ++i) { IntPairPair expectedRange = expectedSelectedRanges.at(i); IntPair expectedTl = expectedRange.first; IntPair expectedBr = expectedRange.second; @@ -1803,21 +1803,21 @@ void tst_QItemSelectionModel::selectedRows() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selectionModel(&model); - for (int i = 0; i < selectRows.count(); ++i) + for (int i = 0; i < selectRows.size(); ++i) selectionModel.select(model.index(selectRows.at(i), 0), QItemSelectionModel::Select |QItemSelectionModel::Rows); - for (int j = 0; j < selectRows.count(); ++j) + for (int j = 0; j < selectRows.size(); ++j) QVERIFY(selectionModel.isRowSelected(expectedRows.at(j), QModelIndex())); - for (int k = 0; k < selectRows.count(); ++k) + for (int k = 0; k < selectRows.size(); ++k) QVERIFY(!selectionModel.isRowSelected(unexpectedRows.at(k), QModelIndex())); QModelIndexList selectedRowIndexes = selectionModel.selectedRows(column); - QCOMPARE(selectedRowIndexes.count(), expectedRows.count()); + QCOMPARE(selectedRowIndexes.size(), expectedRows.size()); std::sort(selectedRowIndexes.begin(), selectedRowIndexes.end()); - for (int l = 0; l < selectedRowIndexes.count(); ++l) { + for (int l = 0; l < selectedRowIndexes.size(); ++l) { QCOMPARE(selectedRowIndexes.at(l).row(), expectedRows.at(l)); QCOMPARE(selectedRowIndexes.at(l).column(), column); } @@ -1863,21 +1863,21 @@ void tst_QItemSelectionModel::selectedColumns() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selectionModel(&model); - for (int i = 0; i < selectColumns.count(); ++i) + for (int i = 0; i < selectColumns.size(); ++i) selectionModel.select(model.index(0, selectColumns.at(i)), QItemSelectionModel::Select |QItemSelectionModel::Columns); - for (int j = 0; j < selectColumns.count(); ++j) + for (int j = 0; j < selectColumns.size(); ++j) QVERIFY(selectionModel.isColumnSelected(expectedColumns.at(j), QModelIndex())); - for (int k = 0; k < selectColumns.count(); ++k) + for (int k = 0; k < selectColumns.size(); ++k) QVERIFY(!selectionModel.isColumnSelected(unexpectedColumns.at(k), QModelIndex())); QModelIndexList selectedColumnIndexes = selectionModel.selectedColumns(row); - QCOMPARE(selectedColumnIndexes.count(), expectedColumns.count()); + QCOMPARE(selectedColumnIndexes.size(), expectedColumns.size()); std::sort(selectedColumnIndexes.begin(), selectedColumnIndexes.end()); - for (int l = 0; l < selectedColumnIndexes.count(); ++l) { + for (int l = 0; l < selectedColumnIndexes.size(); ++l) { QCOMPARE(selectedColumnIndexes.at(l).column(), expectedColumns.at(l)); QCOMPARE(selectedColumnIndexes.at(l).row(), row); } @@ -1908,18 +1908,18 @@ void tst_QItemSelectionModel::setCurrentIndex() treemodel->index(0, 0, treemodel->index(1, 0)), QItemSelectionModel::SelectCurrent); - QCOMPARE(currentSpy.count(), 1); - QCOMPARE(rowSpy.count(), 1); - QCOMPARE(columnSpy.count(), 1); + QCOMPARE(currentSpy.size(), 1); + QCOMPARE(rowSpy.size(), 1); + QCOMPARE(columnSpy.size(), 1); // Select another row in the same parent selectionModel.setCurrentIndex( treemodel->index(1, 0, treemodel->index(1, 0)), QItemSelectionModel::SelectCurrent); - QCOMPARE(currentSpy.count(), 2); - QCOMPARE(rowSpy.count(), 2); - QCOMPARE(columnSpy.count(), 1); + QCOMPARE(currentSpy.size(), 2); + QCOMPARE(rowSpy.size(), 2); + QCOMPARE(columnSpy.size(), 1); } void tst_QItemSelectionModel::splitOnInsert() @@ -2043,14 +2043,14 @@ void tst_QItemSelectionModel::unselectable() } QItemSelectionModel selectionModel(&model); selectionModel.select(QItemSelection(model.index(0, 0), model.index(9, 0)), QItemSelectionModel::Select); - QCOMPARE(selectionModel.selectedIndexes().count(), 10); - QCOMPARE(selectionModel.selectedRows().count(), 10); + QCOMPARE(selectionModel.selectedIndexes().size(), 10); + QCOMPARE(selectionModel.selectedRows().size(), 10); QVERIFY(selectionModel.hasSelection()); for (int j = 0; j < 10; ++j) model.item(j)->setFlags({ }); QVERIFY(!selectionModel.hasSelection()); - QCOMPARE(selectionModel.selectedIndexes().count(), 0); - QCOMPARE(selectionModel.selectedRows().count(), 0); + QCOMPARE(selectionModel.selectedIndexes().size(), 0); + QCOMPARE(selectionModel.selectedRows().size(), 0); } void tst_QItemSelectionModel::selectedIndexes() @@ -2064,8 +2064,8 @@ void tst_QItemSelectionModel::selectedIndexes() //we select the 1st row selectionModel.select(selection, QItemSelectionModel::Rows | QItemSelectionModel::Select); - QCOMPARE(selectionModel.selectedRows().count(), 1); - QCOMPARE(selectionModel.selectedIndexes().count(), model.columnCount()); + QCOMPARE(selectionModel.selectedRows().size(), 1); + QCOMPARE(selectionModel.selectedIndexes().size(), model.columnCount()); } @@ -2103,14 +2103,14 @@ void tst_QItemSelectionModel::layoutChanged() QtTestTableModel model(1,1); QItemSelectionModel selectionModel(&model); selectionModel.select(model.index(0,0), QItemSelectionModel::Select); - QCOMPARE(selectionModel.selectedIndexes().count() , 1); + QCOMPARE(selectionModel.selectedIndexes().size() , 1); emit model.layoutAboutToBeChanged(); model.row_count = 5; emit model.layoutChanged(); //The selection should not change. - QCOMPARE(selectionModel.selectedIndexes().count() , 1); + QCOMPARE(selectionModel.selectedIndexes().size() , 1); QCOMPARE(selectionModel.selectedIndexes().first() , model.index(0,0)); } @@ -2190,7 +2190,7 @@ void tst_QItemSelectionModel::isRowSelected() model.setData(model.index(0,0), 0, Qt::UserRole - 1); QItemSelectionModel sel(&model); sel.select( QItemSelection(model.index(0,0), model.index(0, 1)), QItemSelectionModel::Select); - QCOMPARE(sel.selectedIndexes().count(), 1); + QCOMPARE(sel.selectedIndexes().size(), 1); QVERIFY(sel.isRowSelected(0, QModelIndex())); } @@ -2215,7 +2215,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(deselectSpy.isValid()); model.removeRows(0, 1, root); - QCOMPARE(deselectSpy.count(), 1); + QCOMPARE(deselectSpy.size(), 1); // More testing stress for the patch. model.clear(); @@ -2244,7 +2244,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QVERIFY(selectionModel.selection().contains(sel2)); deselectSpy.clear(); model.removeRow(0, model.index(0, 0)); - QCOMPARE(deselectSpy.count(), 1); + QCOMPARE(deselectSpy.size(), 1); QVERIFY(!selectionModel.selection().contains(sel)); QVERIFY(selectionModel.selection().contains(sel2)); } @@ -2266,7 +2266,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() selection.select(QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select); //let's check the selection hasn't changed - QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + QCOMPARE(selection.selectedIndexes().size(), indexList.size()); for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); @@ -2274,7 +2274,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() QCOMPARE(proxy.rowCount(), 3); //let's check the selection hasn't changed - QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + QCOMPARE(selection.selectedIndexes().size(), indexList.size()); for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); } @@ -2323,7 +2323,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2() QCOMPARE(proxy.rowCount(), int(cNumRows)); //let's check the selection hasn't changed - QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + QCOMPARE(selection.selectedIndexes().size(), indexList.size()); for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); } @@ -2347,11 +2347,11 @@ void tst_QItemSelectionModel::layoutChangedTreeSelection() selModel.select(sub23.index(), QItemSelectionModel::Select); QModelIndexList list = selModel.selectedIndexes(); - QCOMPARE(list.count(), 4); + QCOMPARE(list.size(), 4); model.sort(0); //this will provoke a relayout - QCOMPARE(selModel.selectedIndexes().count(), 4); + QCOMPARE(selModel.selectedIndexes().size(), 4); } class RemovalObserver : public QObject @@ -2410,7 +2410,7 @@ void tst_QItemSelectionModel::setModel() QStringListModel model(QStringList() << "Blah" << "Blah" << "Blah"); sel.setModel(&model); QCOMPARE(sel.model(), &model); - QCOMPARE(modelChangedSpy.count(), 1); + QCOMPARE(modelChangedSpy.size(), 1); sel.select(model.index(0), QItemSelectionModel::Select); QVERIFY(!sel.selection().isEmpty()); sel.setModel(0); @@ -2777,7 +2777,7 @@ void tst_QItemSelectionModel::QTBUG58851() QVERIFY(selections.isSelected(i)); } proxy.sort(1, Qt::DescendingOrder); - QCOMPARE(selections.selectedIndexes().count(), (int)expectedSelectedIndexes.size()); + QCOMPARE(selections.selectedIndexes().size(), (int)expectedSelectedIndexes.size()); for (const QPersistentModelIndex &i : expectedSelectedIndexes) { QVERIFY(selections.isSelected(i)); } @@ -2851,12 +2851,12 @@ void tst_QItemSelectionModel::QTBUG18001() QItemSelectionModel selectionModel(&model); - for (int i = 0; i < indexesToSelect.count(); ++i) { + for (int i = 0; i < indexesToSelect.size(); ++i) { QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second ); selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i))); } - for (int i = 0; i < expectedSelectedRows.count(); ++i) { + for (int i = 0; i < expectedSelectedRows.size(); ++i) { const bool expected = expectedSelectedRows.at(i); const bool actual = selectionModel.isRowSelected(i, QModelIndex()); QByteArray description = QByteArray("Row ") + QByteArray::number(i) @@ -2865,7 +2865,7 @@ void tst_QItemSelectionModel::QTBUG18001() QVERIFY2(expected == actual, description.data()); } - for (int i = 0; i < expectedSelectedColums.count(); ++i) { + for (int i = 0; i < expectedSelectedColums.size(); ++i) { const bool expected = expectedSelectedColums.at(i); const bool actual = selectionModel.isColumnSelected(i, QModelIndex()); QByteArray description = QByteArray("Col ") + QByteArray::number(i) @@ -2888,7 +2888,7 @@ void tst_QItemSelectionModel::QTBUG93305() QModelIndex index = model->index(1, 0, QModelIndex()); selection->select(index, QItemSelectionModel::ClearAndSelect); QVERIFY(selection->hasSelection()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // removing row 0 does not change which cells are selected, but it // does change the row number of the selected cells. Thus it changes @@ -2899,7 +2899,7 @@ void tst_QItemSelectionModel::QTBUG93305() // delete row 0 model->removeRows(0, 1, QModelIndex()); QVERIFY(selection->hasSelection()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); // inserting a row before the first row again does not change which cells // are selected, but does change the row number of the selected cells. @@ -2909,12 +2909,12 @@ void tst_QItemSelectionModel::QTBUG93305() // insert row 0 again model->insertRows(0, 1, QModelIndex()); QVERIFY(selection->hasSelection()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); // test for inserting multiple (6) rows model->insertRows(0, 6, QModelIndex()); QVERIFY(selection->hasSelection()); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); } QTEST_MAIN(tst_QItemSelectionModel) diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 99151a2065..dacfa8e656 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -216,16 +216,16 @@ void tst_QSortFilterProxyModel::sort() // prepare model QStandardItem *root = m_model->invisibleRootItem (); QList<QStandardItem *> items; - for (int i = 0; i < initial.count(); ++i) { + for (int i = 0; i < initial.size(); ++i) { items.append(new QStandardItem(initial.at(i))); } root->insertRows(0, items); - QCOMPARE(m_model->rowCount(QModelIndex()), initial.count()); + QCOMPARE(m_model->rowCount(QModelIndex()), initial.size()); QCOMPARE(m_model->columnCount(QModelIndex()), 1); // make sure the proxy is unsorted QCOMPARE(m_proxy->columnCount(QModelIndex()), 1); - QCOMPARE(m_proxy->rowCount(QModelIndex()), initial.count()); + QCOMPARE(m_proxy->rowCount(QModelIndex()), initial.size()); for (int row = 0; row < m_proxy->rowCount(QModelIndex()); ++row) { QModelIndex index = m_proxy->index(row, 0, QModelIndex()); QCOMPARE(m_proxy->data(index, Qt::DisplayRole).toString(), initial.at(row)); @@ -413,10 +413,10 @@ void tst_QSortFilterProxyModel::insertRows() QFETCH(QStringList, insert); QFETCH(int, position); // prepare model - m_model->insertRows(0, initial.count(), QModelIndex()); + m_model->insertRows(0, initial.size(), QModelIndex()); //m_model->insertColumns(0, 1, QModelIndex()); QCOMPARE(m_model->columnCount(QModelIndex()), 1); - QCOMPARE(m_model->rowCount(QModelIndex()), initial.count()); + QCOMPARE(m_model->rowCount(QModelIndex()), initial.size()); for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) { QModelIndex index = m_model->index(row, 0, QModelIndex()); m_model->setData(index, initial.at(row), Qt::DisplayRole); @@ -433,12 +433,12 @@ void tst_QSortFilterProxyModel::insertRows() } // insert the row - m_proxy->insertRows(position, insert.count(), QModelIndex()); - QCOMPARE(m_model->rowCount(QModelIndex()), expected.count()); - QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.count()); + m_proxy->insertRows(position, insert.size(), QModelIndex()); + QCOMPARE(m_model->rowCount(QModelIndex()), expected.size()); + QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.size()); // set the data for the inserted row - for (int i = 0; i < insert.count(); ++i) { + for (int i = 0; i < insert.size(); ++i) { QModelIndex index = m_proxy->index(position + i, 0, QModelIndex()); m_proxy->setData(index, insert.at(i), Qt::DisplayRole); } @@ -827,8 +827,8 @@ void tst_QSortFilterProxyModel::removeRows() // remove the rows QCOMPARE(proxy.removeRows(position, count, QModelIndex()), success); - QCOMPARE(model.rowCount(QModelIndex()), expectedSource.count()); - QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxy.count()); + QCOMPARE(model.rowCount(QModelIndex()), expectedSource.size()); + QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxy.size()); // make sure the model is correct after remove for (int row = 0; row < model.rowCount(QModelIndex()); ++row) @@ -1073,8 +1073,8 @@ void tst_QSortFilterProxyModel::removeColumns() // remove the columns QCOMPARE(proxy.removeColumns(position, count, QModelIndex()), success); - QCOMPARE(model.columnCount(QModelIndex()), expectedSource.count()); - QCOMPARE(proxy.columnCount(QModelIndex()), expectedProxy.count()); + QCOMPARE(model.columnCount(QModelIndex()), expectedSource.size()); + QCOMPARE(proxy.columnCount(QModelIndex()), expectedProxy.size()); // make sure the model is correct after remove for (int col = 0; col < model.columnCount(QModelIndex()); ++col) @@ -1124,9 +1124,9 @@ void tst_QSortFilterProxyModel::filterColumns() QFETCH(QStringList, initial); QFETCH(bool, data); // prepare model - m_model->setColumnCount(initial.count()); + m_model->setColumnCount(initial.size()); m_model->setRowCount(1); - QCOMPARE(m_model->columnCount(QModelIndex()), initial.count()); + QCOMPARE(m_model->columnCount(QModelIndex()), initial.size()); QCOMPARE(m_model->rowCount(QModelIndex()), 1); // set data QCOMPARE(m_model->rowCount(QModelIndex()), 1); @@ -1203,8 +1203,8 @@ void tst_QSortFilterProxyModel::filter() QFETCH(QStringList, expected); // prepare model - QVERIFY(m_model->insertRows(0, initial.count(), QModelIndex())); - QCOMPARE(m_model->rowCount(QModelIndex()), initial.count()); + QVERIFY(m_model->insertRows(0, initial.size(), QModelIndex())); + QCOMPARE(m_model->rowCount(QModelIndex()), initial.size()); // set data QCOMPARE(m_model->columnCount(QModelIndex()), 1); for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) { @@ -1214,7 +1214,7 @@ void tst_QSortFilterProxyModel::filter() setupFilter(m_proxy, pattern); // make sure the proxy is unfiltered QCOMPARE(m_proxy->columnCount(QModelIndex()), 1); - QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.count()); + QCOMPARE(m_proxy->rowCount(QModelIndex()), expected.size()); // make sure the model is unchanged for (int row = 0; row < m_model->rowCount(QModelIndex()); ++row) { QModelIndex index = m_model->index(row, 0, QModelIndex()); @@ -1262,7 +1262,7 @@ void tst_QSortFilterProxyModel::buildHierarchy(const QStringList &l, QAbstractIt QStack<int> row_stack; QModelIndex parent; QStack<QModelIndex> parent_stack; - for (int i = 0; i < l.count(); ++i) { + for (int i = 0; i < l.size(); ++i) { QString token = l.at(i); if (token == QLatin1String("<")) { // start table ++ind; @@ -1292,7 +1292,7 @@ void tst_QSortFilterProxyModel::checkHierarchy(const QStringList &l, const QAbst QStack<int> row_stack; QModelIndex parent; QStack<QModelIndex> parent_stack; - for (int i = 0; i < l.count(); ++i) { + for (int i = 0; i < l.size(); ++i) { QString token = l.at(i); if (token == QLatin1String("<")) { // start table ++indent; @@ -1402,9 +1402,9 @@ void tst_QSortFilterProxyModel::filterCurrent() QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); setupFilter(&proxy, QLatin1String("^B")); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QSortFilterProxyModel::filter_qtbug30662() @@ -1472,7 +1472,7 @@ void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut() // Filter everything out setupFilter(&proxy, QLatin1String("c")); - QCOMPARE(removeSpy.count(), 1); + QCOMPARE(removeSpy.size(), 1); QCOMPARE(0, proxy.rowCount()); // change layout of source model @@ -1482,7 +1482,7 @@ void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut() // Remove filter; we expect an insert setupFilter(&proxy, ""); - QCOMPARE(insertSpy.count(), 1); + QCOMPARE(insertSpy.size(), 1); QCOMPARE(beforeSortFilter, proxy.rowCount()); } @@ -1561,9 +1561,9 @@ void tst_QSortFilterProxyModel::removeSourceRows() proxy.setSourceModel(&model); model.insertColumns(0, 1); - model.insertRows(0, sourceItems.count()); + model.insertRows(0, sourceItems.size()); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex sindex = model.index(i, 0, QModelIndex()); model.setData(sindex, sourceItems.at(i), Qt::DisplayRole); QModelIndex pindex = proxy.index(i, 0, QModelIndex()); @@ -1586,16 +1586,16 @@ void tst_QSortFilterProxyModel::removeSourceRows() model.removeRows(start, count, QModelIndex()); - QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count()); - for (int i = 0; i < aboutToRemoveSpy.count(); ++i) { + QCOMPARE(aboutToRemoveSpy.size(), expectedRemovedProxyIntervals.size()); + for (int i = 0; i < aboutToRemoveSpy.size(); ++i) { const auto &args = aboutToRemoveSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } - QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count()); - for (int i = 0; i < removeSpy.count(); ++i) { + QCOMPARE(removeSpy.size(), expectedRemovedProxyIntervals.size()); + for (int i = 0; i < removeSpy.size(); ++i) { const auto &args = removeSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -1603,11 +1603,11 @@ void tst_QSortFilterProxyModel::removeSourceRows() QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } - QCOMPARE(insertSpy.count(), 0); - QCOMPARE(aboutToInsertSpy.count(), 0); + QCOMPARE(insertSpy.size(), 0); + QCOMPARE(aboutToInsertSpy.size(), 0); - QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.count()); - for (int i = 0; i < expectedProxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.size()); + for (int i = 0; i < expectedProxyItems.size(); ++i) { QModelIndex pindex = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(pindex, Qt::DisplayRole).toString(), expectedProxyItems.at(i)); } @@ -1654,9 +1654,9 @@ void tst_QSortFilterProxyModel::insertSourceRows() proxy.setSourceModel(&model); model.insertColumns(0, 1); - model.insertRows(0, sourceItems.count()); + model.insertRows(0, sourceItems.size()); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex index = model.index(i, 0, QModelIndex()); model.setData(index, sourceItems.at(i), Qt::DisplayRole); } @@ -1666,13 +1666,13 @@ void tst_QSortFilterProxyModel::insertSourceRows() model.insertRows(start, newItems.size(), QModelIndex()); - QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.count()); - for (int i = 0; i < newItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.size()); + for (int i = 0; i < newItems.size(); ++i) { QModelIndex index = model.index(start + i, 0, QModelIndex()); model.setData(index, newItems.at(i), Qt::DisplayRole); } - for (int i = 0; i < proxyItems.count(); ++i) { + for (int i = 0; i < proxyItems.size(); ++i) { QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), proxyItems.at(i)); } @@ -1745,9 +1745,9 @@ void tst_QSortFilterProxyModel::changeFilter() proxy.setSourceModel(&model); model.insertColumns(0, 1); - model.insertRows(0, sourceItems.count()); + model.insertRows(0, sourceItems.size()); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex index = model.index(i, 0, QModelIndex()); model.setData(index, sourceItems.at(i), Qt::DisplayRole); } @@ -1763,9 +1763,9 @@ void tst_QSortFilterProxyModel::changeFilter() setupFilter(&proxy, initialFilter); - QCOMPARE(initialRemoveSpy.count(), initialRemoveIntervals.count()); - QCOMPARE(initialInsertSpy.count(), 0); - for (int i = 0; i < initialRemoveSpy.count(); ++i) { + QCOMPARE(initialRemoveSpy.size(), initialRemoveIntervals.size()); + QCOMPARE(initialInsertSpy.size(), 0); + for (int i = 0; i < initialRemoveSpy.size(); ++i) { const auto &args = initialRemoveSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -1773,8 +1773,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(args.at(2).toInt(), initialRemoveIntervals.at(i).second); } - QCOMPARE(proxy.rowCount(QModelIndex()), initialProxyItems.count()); - for (int i = 0; i < initialProxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), initialProxyItems.size()); + for (int i = 0; i < initialProxyItems.size(); ++i) { QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initialProxyItems.at(i)); } @@ -1787,8 +1787,8 @@ void tst_QSortFilterProxyModel::changeFilter() setupFilter(&proxy, finalFilter); - QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count()); - for (int i = 0; i < finalRemoveSpy.count(); ++i) { + QCOMPARE(finalRemoveSpy.size(), finalRemoveIntervals.size()); + for (int i = 0; i < finalRemoveSpy.size(); ++i) { const auto &args = finalRemoveSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -1796,8 +1796,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(args.at(2).toInt(), finalRemoveIntervals.at(i).second); } - QCOMPARE(finalInsertSpy.count(), insertIntervals.count()); - for (int i = 0; i < finalInsertSpy.count(); ++i) { + QCOMPARE(finalInsertSpy.size(), insertIntervals.size()); + for (int i = 0; i < finalInsertSpy.size(); ++i) { const auto &args = finalInsertSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -1805,8 +1805,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second); } - QCOMPARE(proxy.rowCount(QModelIndex()), finalProxyItems.count()); - for (int i = 0; i < finalProxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), finalProxyItems.size()); + for (int i = 0; i < finalProxyItems.size(); ++i) { QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), finalProxyItems.at(i)); } @@ -1969,9 +1969,9 @@ void tst_QSortFilterProxyModel::changeSourceData() proxy.setDynamicSortFilter(dynamic); proxy.setSourceModel(&model); model.insertColumns(0, 1); - model.insertRows(0, sourceItems.count()); + model.insertRows(0, sourceItems.size()); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex index = model.index(i, 0, QModelIndex()); model.setData(index, sourceItems.at(i), Qt::DisplayRole); } @@ -1981,8 +1981,8 @@ void tst_QSortFilterProxyModel::changeSourceData() setupFilter(&proxy, filter); - QCOMPARE(proxy.rowCount(), expectedInitialProxyItems.count()); - for (int i = 0; i < expectedInitialProxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(), expectedInitialProxyItems.size()); + for (int i = 0; i < expectedInitialProxyItems.size(); ++i) { const QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expectedInitialProxyItems.at(i)); } @@ -2002,8 +2002,8 @@ void tst_QSortFilterProxyModel::changeSourceData() model.setData(index, newValue, Qt::DisplayRole); } - QCOMPARE(removeSpy.count(), removeIntervals.count()); - for (int i = 0; i < removeSpy.count(); ++i) { + QCOMPARE(removeSpy.size(), removeIntervals.size()); + for (int i = 0; i < removeSpy.size(); ++i) { const auto &args = removeSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -2011,8 +2011,8 @@ void tst_QSortFilterProxyModel::changeSourceData() QCOMPARE(args.at(2).toInt(), removeIntervals.at(i).second); } - QCOMPARE(insertSpy.count(), insertIntervals.count()); - for (int i = 0; i < insertSpy.count(); ++i) { + QCOMPARE(insertSpy.size(), insertIntervals.size()); + for (int i = 0; i < insertSpy.size(); ++i) { const auto &args = insertSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -2020,29 +2020,29 @@ void tst_QSortFilterProxyModel::changeSourceData() QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second); } - QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.count()); - for (int i = 0; i < proxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), proxyItems.size()); + for (int i = 0; i < proxyItems.size(); ++i) { QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), proxyItems.at(i)); } if (expectedDataChangedRow == -1) { - QCOMPARE(dataChangedSpy.count(), 0); + QCOMPARE(dataChangedSpy.size(), 0); } else { - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); const QModelIndex idx = dataChangedSpy.at(0).at(0).value<QModelIndex>(); QCOMPARE(idx.row(), expectedDataChangedRow); QCOMPARE(idx.column(), 0); } - QCOMPARE(layoutChangedSpy.count(), expectedLayoutChanged ? 1 : 0); + QCOMPARE(layoutChangedSpy.size(), expectedLayoutChanged ? 1 : 0); } // Checks that the model is a table, and that each and every row is like this: // i-th row: ( rows.at(i), i ) static void checkSortedTableModel(const QAbstractItemModel *model, const QStringList &rows) { - QCOMPARE(model->rowCount(), rows.length()); + QCOMPARE(model->rowCount(), rows.size()); QCOMPARE(model->columnCount(), 2); for (int row = 0; row < model->rowCount(); ++row) { @@ -2066,7 +2066,7 @@ void tst_QSortFilterProxyModel::changeSourceDataKeepsStableSorting_qtbug1548() // Build a table of pairs (string, #row) in each row QStandardItemModel model(0, 2); - for (int rowNumber = 0; rowNumber < rows.length(); ++rowNumber) { + for (int rowNumber = 0; rowNumber < rows.size(); ++rowNumber) { QStandardItem *column0 = new QStandardItem(rows.at(rowNumber)); column0->setCheckable(true); column0->setCheckState(Qt::Unchecked); @@ -2120,7 +2120,7 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440() QSignalSpy spy(&proxy, &QAbstractItemModel::dataChanged); QVERIFY(spy.isValid()); - QCOMPARE(spy.length(), 0); + QCOMPARE(spy.size(), 0); QModelIndex index; @@ -2133,13 +2133,13 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440() index = model.index(0, 0); QVERIFY(index.isValid()); model.setData(index, QStringLiteral("teststring"), Qt::DisplayRole); - QCOMPARE(spy.length(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(2).value<QList<int> >(), expectedChangedRoles); index = model.index(1, 0); QVERIFY(index.isValid()); model.setData(index, QStringLiteral("teststring2"), Qt::EditRole); - QCOMPARE(spy.length(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(spy.at(1).at(2).value<QList<int> >(), expectedChangedRoles); } @@ -2386,8 +2386,8 @@ void tst_QSortFilterProxyModel::sortFilterRole() const QList<int> orderedItems({2, 1}); - model.insertRows(0, sourceItems.count()); - for (int i = 0; i < sourceItems.count(); ++i) { + model.insertRows(0, sourceItems.size()); + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex index = model.index(i, 0, QModelIndex()); model.setData(index, sourceItems.at(i).first, Qt::DisplayRole); model.setData(index, sourceItems.at(i).second, Qt::UserRole); @@ -2417,7 +2417,7 @@ void tst_QSortFilterProxyModel::sortFilterRole() proxy.setFilterRole(Qt::DisplayRole); setupFilter(&proxy, QLatin1String("a|c")); - QCOMPARE(proxy.rowCount(), orderedItems.count()); + QCOMPARE(proxy.rowCount(), orderedItems.size()); for (int i = 0; i < proxy.rowCount(); ++i) { QModelIndex index = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole), sourceItems.at(orderedItems.at(i)).first); @@ -2439,10 +2439,10 @@ void tst_QSortFilterProxyModel::selectionFilteredOut() QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); setupFilter(&proxy, QLatin1String("^B")); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QSortFilterProxyModel::match_data() @@ -2519,9 +2519,9 @@ void tst_QSortFilterProxyModel::match() proxy.setSourceModel(&model); model.insertColumns(0, 1); - model.insertRows(0, sourceItems.count()); + model.insertRows(0, sourceItems.size()); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex index = model.index(i, 0, QModelIndex()); model.setData(index, sourceItems.at(i), Qt::DisplayRole); } @@ -2531,10 +2531,10 @@ void tst_QSortFilterProxyModel::match() QModelIndex startIndex = proxy.index(proxyStartRow, 0); QModelIndexList indexes = proxy.match(startIndex, Qt::DisplayRole, what, - expectedProxyItems.count(), + expectedProxyItems.size(), matchFlags); - QCOMPARE(indexes.count(), expectedProxyItems.count()); - for (int i = 0; i < indexes.count(); ++i) + QCOMPARE(indexes.size(), expectedProxyItems.size()); + for (int i = 0; i < indexes.size(); ++i) QCOMPARE(indexes.at(i).row(), expectedProxyItems.at(i)); } @@ -2597,13 +2597,13 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem() QVERIFY(rowsInsertedSpy.isValid()); (void)proxy.rowCount(QModelIndex()); // force mapping of "a", "b", "c" - QCOMPARE(colsInsertedSpy.count(), 0); - QCOMPARE(rowsInsertedSpy.count(), 0); + QCOMPARE(colsInsertedSpy.size(), 0); + QCOMPARE(rowsInsertedSpy.size(), 0); // now add a child to itemB ==> should get insert notification from the proxy itemB->appendRow(new QStandardItem("a.0")); - QCOMPARE(colsInsertedSpy.count(), 1); - QCOMPARE(rowsInsertedSpy.count(), 1); + QCOMPARE(colsInsertedSpy.size(), 1); + QCOMPARE(rowsInsertedSpy.size(), 1); QVariantList args = colsInsertedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), proxy.mapFromSource(itemB->index())); @@ -2679,11 +2679,11 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent() QStandardItem *itemB = new QStandardItem(); itemA->appendRow(itemB); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); itemA->removeRow(0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild() @@ -2710,9 +2710,9 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild() setupFilter(&proxy, QLatin1String("C")); // A and B will be filtered out, C filtered in // we should now have been notified that the subtree represented by itemA has been removed - QCOMPARE(removedSpy.count(), 1); + QCOMPARE(removedSpy.size(), 1); // we should NOT get any inserts; itemC should be filtered because its parent (itemA) is - QCOMPARE(insertedSpy.count(), 0); + QCOMPARE(insertedSpy.size(), 0); } void tst_QSortFilterProxyModel::sourceInsertRows() @@ -2805,7 +2805,7 @@ void tst_QSortFilterProxyModel::sortColumnTracking2() model.insertColumn(0,items); QCOMPARE(proxyModel.sortColumn(), 0); QCOMPARE(proxyModel.data(proxyModel.index(0,0)).toString(),QString::fromLatin1("aa")); - const int zzIndex = items.count() - 3; // 2 invalid at end. + const int zzIndex = items.size() - 3; // 2 invalid at end. QCOMPARE(proxyModel.data(proxyModel.index(zzIndex,0)).toString(),QString::fromLatin1("zz")); } @@ -2897,16 +2897,16 @@ void tst_QSortFilterProxyModel::staticSorting() // prepare model QStandardItem *root = model.invisibleRootItem (); QList<QStandardItem *> items; - for (int i = 0; i < initial.count(); ++i) { + for (int i = 0; i < initial.size(); ++i) { items.append(new QStandardItem(initial.at(i))); } root->insertRows(0, items); - QCOMPARE(model.rowCount(QModelIndex()), initial.count()); + QCOMPARE(model.rowCount(QModelIndex()), initial.size()); QCOMPARE(model.columnCount(QModelIndex()), 1); // make sure the proxy is unsorted QCOMPARE(proxy.columnCount(QModelIndex()), 1); - QCOMPARE(proxy.rowCount(QModelIndex()), initial.count()); + QCOMPARE(proxy.rowCount(QModelIndex()), initial.size()); for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) { QModelIndex index = proxy.index(row, 0, QModelIndex()); QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initial.at(row)); @@ -2956,7 +2956,7 @@ void tst_QSortFilterProxyModel::dynamicSorting() QCOMPARE(proxy1.columnCount(QModelIndex()), 1); //the model should not be sorted because sorting has not been set to dynamic yet. - QCOMPARE(proxy1.rowCount(QModelIndex()), initial.count()); + QCOMPARE(proxy1.rowCount(QModelIndex()), initial.size()); for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) { QModelIndex index = proxy1.index(row, 0, QModelIndex()); QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), initial.at(row)); @@ -3227,7 +3227,7 @@ void tst_QSortFilterProxyModel::removeRowsRecursive() QList<QStandardItem*> itemRow = pItem1->takeRow(0); - QCOMPARE(itemRow.count(), 1); + QCOMPARE(itemRow.size(), 1); QCOMPARE(itemRow.first(), pItem11); for (const auto &pidx : qAsConst(sourceIndexes)) @@ -3266,7 +3266,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() QItemSelectionModel ism(proxyModel); ism.select(mi, QItemSelectionModel::Select); QModelIndexList mil = ism.selectedIndexes(); - QCOMPARE(mil.count(), 1); + QCOMPARE(mil.size(), 1); QCOMPARE(mil.first(), mi); toggleProxy->setSourceModel(model2); @@ -3337,10 +3337,10 @@ void tst_QSortFilterProxyModel::appearsAndSort() QCOMPARE(secondProxyModel.data(secondProxyModel.index(1,0), Qt::DisplayRole).toString(), QString::fromLatin1("b")); QCOMPARE(secondProxyModel.data(secondProxyModel.index(2,0), Qt::DisplayRole).toString(), QString::fromLatin1("a")); - QCOMPARE(spyAbout1.count(), 1); - QCOMPARE(spyChanged1.count(), 1); - QCOMPARE(spyAbout2.count(), 1); - QCOMPARE(spyChanged2.count(), 1); + QCOMPARE(spyAbout1.size(), 1); + QCOMPARE(spyChanged1.size(), 1); + QCOMPARE(spyAbout2.size(), 1); + QCOMPARE(spyChanged2.size(), 1); } void tst_QSortFilterProxyModel::unnecessaryDynamicSorting() @@ -4647,7 +4647,7 @@ public: return lst.at(index.row()); return QVariant(); } - int rowCount(const QModelIndex & = QModelIndex()) const override { return lst.count(); } + int rowCount(const QModelIndex & = QModelIndex()) const override { return lst.size(); } void replaceData(const QStringList &newData) { @@ -4788,7 +4788,7 @@ void tst_QSortFilterProxyModel::removeIntervals() model.replaceData(sourceItems); proxy.setSourceModel(&model); - for (int i = 0; i < sourceItems.count(); ++i) { + for (int i = 0; i < sourceItems.size(); ++i) { QModelIndex sindex = model.index(i, 0, QModelIndex()); QModelIndex pindex = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(pindex, Qt::DisplayRole), model.data(sindex, Qt::DisplayRole)); @@ -4813,16 +4813,16 @@ void tst_QSortFilterProxyModel::removeIntervals() model.replaceData(replacementSourceItems); - QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count()); - for (int i = 0; i < aboutToRemoveSpy.count(); ++i) { + QCOMPARE(aboutToRemoveSpy.size(), expectedRemovedProxyIntervals.size()); + for (int i = 0; i < aboutToRemoveSpy.size(); ++i) { const auto &args = aboutToRemoveSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } - QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count()); - for (int i = 0; i < removeSpy.count(); ++i) { + QCOMPARE(removeSpy.size(), expectedRemovedProxyIntervals.size()); + for (int i = 0; i < removeSpy.size(); ++i) { const auto &args = removeSpy.at(i); QCOMPARE(args.at(1).userType(), QMetaType::Int); QCOMPARE(args.at(2).userType(), QMetaType::Int); @@ -4830,11 +4830,11 @@ void tst_QSortFilterProxyModel::removeIntervals() QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } - QCOMPARE(insertSpy.count(), 0); - QCOMPARE(aboutToInsertSpy.count(), 0); + QCOMPARE(insertSpy.size(), 0); + QCOMPARE(aboutToInsertSpy.size(), 0); - QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.count()); - for (int i = 0; i < expectedProxyItems.count(); ++i) { + QCOMPARE(proxy.rowCount(QModelIndex()), expectedProxyItems.size()); + for (int i = 0; i < expectedProxyItems.size(); ++i) { QModelIndex pindex = proxy.index(i, 0, QModelIndex()); QCOMPARE(proxy.data(pindex, Qt::DisplayRole).toString(), expectedProxyItems.at(i)); } @@ -4861,7 +4861,7 @@ void tst_QSortFilterProxyModel::dynamicFilterWithoutSort() QCOMPARE(model.stringList(), QStringList() << "Monday" << "Tuesday" << "Wednesday" << "Thursday" << "Friday"); - QCOMPARE(resetSpy.count(), 1); + QCOMPARE(resetSpy.size(), 1); } void tst_QSortFilterProxyModel::checkSetNewModel() @@ -5114,7 +5114,7 @@ void tst_QSortFilterProxyModel::filterAndInsertRow() QVERIFY(proxyModel.insertRow(row)); QCOMPARE(model.stringList(), expectedModelList); - QCOMPARE(proxyModel.rowCount(), expectedProxyModelList.count()); + QCOMPARE(proxyModel.rowCount(), expectedProxyModelList.size()); for (int r = 0; r < proxyModel.rowCount(); ++r) { QModelIndex index = proxyModel.index(r, 0); QVERIFY(index.isValid()); @@ -5387,7 +5387,7 @@ void tst_QSortFilterProxyModel::filterCaseSensitivityBinding() QRegularExpression regExp("pattern", QRegularExpression::CaseInsensitiveOption); proxyModel.setFilterRegularExpression(regExp); QCOMPARE(proxyModel.filterCaseSensitivity(), Qt::CaseInsensitive); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!proxyModel.bindableFilterCaseSensitivity().hasBinding()); } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp index a880f8d204..eb137d4821 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp @@ -119,7 +119,7 @@ static void fillModel(QStandardItemModel &model, const QString &str) QCOMPARE(str.count('['), str.count(']')); QStandardItem *item = nullptr; QString data; - for ( int i = 0 ; i < str.length() ; ++i ) { + for ( int i = 0 ; i < str.size() ; ++i ) { const QChar ch = str.at(i); if ((ch == '[' || ch == ']' || ch == ' ') && !data.isEmpty()) { if (data.endsWith('*')) { diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp index bce7b1733d..b99269d81c 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp @@ -118,12 +118,12 @@ void tst_QSortFilterProxyModelRegularExpression::tst_regexCaseSensitivityNotific QSortFilterProxyModel proxy; QSignalSpy spy(&proxy, &QSortFilterProxyModel::filterCaseSensitivityChanged); proxy.setFilterCaseSensitivity(Qt::CaseInsensitive); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QRegularExpression re("regex"); QVERIFY(!re.patternOptions().testFlag(QRegularExpression::CaseInsensitiveOption)); proxy.setFilterRegularExpression(re); QCOMPARE(proxy.filterCaseSensitivity(), Qt::CaseSensitive); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } QTEST_MAIN(tst_QSortFilterProxyModelRegularExpression) diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index ac2eda0ef0..084b7c5f0c 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -406,7 +406,7 @@ void tst_QStringListModel::setData_emits_on_change_only() const QModelIndex modelIdx = model.index(0, 0); const QString newStringData = QStringLiteral("test"); QVERIFY(model.setData(modelIdx, newStringData)); - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); const QList<QVariant> spyList = dataChangedSpy.takeFirst(); QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx); QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx); diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp index 353d700e2d..8d34f0a574 100644 --- a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp @@ -264,8 +264,8 @@ void tst_QTransposeProxyModel::sort() QVERIFY(layoutAboutToBeChangedSpy.isValid()); QPersistentModelIndex firstIndexBeforeSort = proxyModel.index(0, 0); baseModel.sort(0, Qt::AscendingOrder); - QCOMPARE(layoutChangedSpy.count(), 1); - QCOMPARE(layoutAboutToBeChangedSpy.count(), 1); + QCOMPARE(layoutChangedSpy.size(), 1); + QCOMPARE(layoutAboutToBeChangedSpy.size(), 1); QCOMPARE(layoutChangedSpy.takeFirst().at(1).toInt(), int(QAbstractItemModel::HorizontalSortHint)); QCOMPARE(firstIndexBeforeSort.data().toString(), firstItemBeforeSort); for (int i = 0; i < 100; ++i) @@ -298,8 +298,8 @@ void tst_QTransposeProxyModel::removeColumnBase() QVERIFY(model->removeColumn(1, parent)); QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount - 1); QCOMPARE(proxy.index(1, 0, proxy.mapFromSource(parent)).data(), expectedNewVal); - QCOMPARE(rowRemoveSpy.count(), 1); - QCOMPARE(rowAboutToBeRemoveSpy.count(), 1); + QCOMPARE(rowRemoveSpy.size(), 1); + QCOMPARE(rowAboutToBeRemoveSpy.size(), 1); for (const auto &spyArgs : {rowRemoveSpy.takeFirst(), rowAboutToBeRemoveSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); @@ -412,8 +412,8 @@ void tst_QTransposeProxyModel::insertColumnBase() QVERIFY(model->insertColumn(1, parent)); QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount + 1); QVERIFY(!proxy.index(1, 0, proxy.mapFromSource(parent)).data().isValid()); - QCOMPARE(rowInsertSpy.count(), 1); - QCOMPARE(rowAboutToBeInsertSpy.count(), 1); + QCOMPARE(rowInsertSpy.size(), 1); + QCOMPARE(rowAboutToBeInsertSpy.size(), 1); for (const auto &spyArgs : {rowInsertSpy.takeFirst(), rowAboutToBeInsertSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); @@ -450,8 +450,8 @@ void tst_QTransposeProxyModel::removeRowBase() QVERIFY(model->removeRow(1, parent)); QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount - 1); QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parent)).data(), expectedNewVal); - QCOMPARE(columnsRemoveSpy.count(), 1); - QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); + QCOMPARE(columnsRemoveSpy.size(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1); for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), columnsAboutToBeRemoveSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); @@ -488,8 +488,8 @@ void tst_QTransposeProxyModel::insertRowBase() QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount + 1); QVariant result = proxy.index(0, 1, proxy.mapFromSource(parent)).data(); QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull())); - QCOMPARE(columnsInsertSpy.count(), 1); - QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); + QCOMPARE(columnsInsertSpy.size(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.size(), 1); for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), columnsAboutToBeInsertSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); @@ -534,10 +534,10 @@ void tst_QTransposeProxyModel::removeColumnProxy() QCOMPARE(model->rowCount(sourceParent), oldRowCount - 1); QCOMPARE(proxy.index(0, 1, proxyParent).data(), expectedNewVal); QCOMPARE(model->index(1, 0, sourceParent).data(), expectedNewVal); - QCOMPARE(columnsRemoveSpy.count(), 1); - QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); - QCOMPARE(rowsRemoveSpy.count(), 1); - QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1); + QCOMPARE(columnsRemoveSpy.size(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1); + QCOMPARE(rowsRemoveSpy.size(), 1); + QCOMPARE(rowsAboutToBeRemoveSpy.size(), 1); for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), columnsAboutToBeRemoveSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); @@ -589,10 +589,10 @@ void tst_QTransposeProxyModel::insertColumnProxy() QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull())); result = model->index(1, 0, sourceParent).data(); QVERIFY(result.isNull() || (result.metaType().id() == QMetaType::QString && result.toString().isNull())); - QCOMPARE(columnsInsertSpy.count(), 1); - QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); - QCOMPARE(rowsInsertSpy.count(), 1); - QCOMPARE(rowsAboutToBeInsertSpy.count(), 1); + QCOMPARE(columnsInsertSpy.size(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.size(), 1); + QCOMPARE(rowsInsertSpy.size(), 1); + QCOMPARE(rowsAboutToBeInsertSpy.size(), 1); for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), columnsAboutToBeInsertSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); @@ -642,10 +642,10 @@ void tst_QTransposeProxyModel::removeRowProxy() QCOMPARE(model->columnCount(sourceParent), oldColCount - 1); QCOMPARE(proxy.index(1, 0, proxyParent).data(), expectedNewVal); QCOMPARE(model->index(0, 1, sourceParent).data(), expectedNewVal); - QCOMPARE(columnsRemoveSpy.count(), 1); - QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); - QCOMPARE(rowsRemoveSpy.count(), 1); - QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1); + QCOMPARE(columnsRemoveSpy.size(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.size(), 1); + QCOMPARE(rowsRemoveSpy.size(), 1); + QCOMPARE(rowsAboutToBeRemoveSpy.size(), 1); for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), columnsAboutToBeRemoveSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); @@ -694,10 +694,10 @@ void tst_QTransposeProxyModel::insertRowProxy() QCOMPARE(model->columnCount(sourceParent), oldColCount + 1); QVERIFY(proxy.index(1, 0, proxyParent).data().isNull()); QVERIFY(model->index(0, 1, sourceParent).data().isNull()); - QCOMPARE(columnsInsertSpy.count(), 1); - QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); - QCOMPARE(rowsInsertSpy.count(), 1); - QCOMPARE(rowsAboutToBeInsertSpy.count(), 1); + QCOMPARE(columnsInsertSpy.size(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.size(), 1); + QCOMPARE(rowsInsertSpy.size(), 1); + QCOMPARE(rowsAboutToBeInsertSpy.size(), 1); for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), columnsAboutToBeInsertSpy.takeFirst()}) { QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); @@ -869,8 +869,8 @@ void tst_QTransposeProxyModel::moveRowsBase() QVERIFY(model.moveRows(QModelIndex(), 0, 1, QModelIndex(), 2)); for (int i = 0; i < expectedNewVal.size(); ++i) QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i)); - QCOMPARE(columnsMoveSpy.count(), 1); - QCOMPARE(columnsAboutToBeMoveSpy.count(), 1); + QCOMPARE(columnsMoveSpy.size(), 1); + QCOMPARE(columnsAboutToBeMoveSpy.size(), 1); for (const auto &spyArgs : {columnsMoveSpy.takeFirst(), columnsAboutToBeMoveSpy.takeFirst()}) { QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid()); @@ -901,10 +901,10 @@ void tst_QTransposeProxyModel::moveColumnsProxy() QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i)); for (int i = 0; i < expectedNewVal.size(); ++i) QCOMPARE(model.index(i, 0).data(), expectedNewVal.at(i)); - QCOMPARE(columnsMoveSpy.count(), 1); - QCOMPARE(columnsAboutToBeMoveSpy.count(), 1); - QCOMPARE(rowsMoveSpy.count(), 1); - QCOMPARE(rowsAboutToBeMoveSpy.count(), 1); + QCOMPARE(columnsMoveSpy.size(), 1); + QCOMPARE(columnsAboutToBeMoveSpy.size(), 1); + QCOMPARE(rowsMoveSpy.size(), 1); + QCOMPARE(rowsAboutToBeMoveSpy.size(), 1); for (const auto &spyArgs : {columnsMoveSpy.takeFirst(), columnsAboutToBeMoveSpy.takeFirst(), rowsMoveSpy.takeFirst(),rowsAboutToBeMoveSpy.takeFirst()}) { diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 8ddca93cb7..46d52c2340 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -175,7 +175,7 @@ void tst_QCoreApplication::argc() char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; TestApplication app(argc, argv); QCOMPARE(argc, 1); - QCOMPARE(app.arguments().count(), 1); + QCOMPARE(app.arguments().size(), 1); } { @@ -186,7 +186,7 @@ void tst_QCoreApplication::argc() const_cast<char*>("arg3") }; TestApplication app(argc, argv); QCOMPARE(argc, 4); - QCOMPARE(app.arguments().count(), 4); + QCOMPARE(app.arguments().size(), 4); } { @@ -194,7 +194,7 @@ void tst_QCoreApplication::argc() char **argv = 0; TestApplication app(argc, argv); QCOMPARE(argc, 0); - QCOMPARE(app.arguments().count(), 0); + QCOMPARE(app.arguments().size(), 0); } { @@ -203,7 +203,7 @@ void tst_QCoreApplication::argc() const_cast<char*>("-qmljsdebugger=port:3768,block") }; TestApplication app(argc, argv); QCOMPARE(argc, 1); - QCOMPARE(app.arguments().count(), 1); + QCOMPARE(app.arguments().size(), 1); } } @@ -1021,7 +1021,7 @@ void tst_QCoreApplication::addRemoveLibPaths() TestApplication app(argc, argv); // If libraryPaths only contains currentDir, neither will be in libraryPaths now. - if (paths.length() != 1 && currentDir != paths[0]) { + if (paths.size() != 1 && currentDir != paths[0]) { // Check that modifications stay alive across the creation of an application. QVERIFY(QCoreApplication::libraryPaths().contains(currentDir)); QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0])); diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index df5f5fef1d..99563f187a 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -159,7 +159,7 @@ private: bool foundCoarse = false; bool foundVeryCoarse = false; const QList<QAbstractEventDispatcher::TimerInfo> timers = registeredTimers(); - for (int i = 0; i < timers.count(); ++i) { + for (int i = 0; i < timers.size(); ++i) { const QAbstractEventDispatcher::TimerInfo &timerInfo = timers.at(i); if (timerInfo.timerId == m_preciseTimerId) { QCOMPARE(timerInfo.interval, int(PreciseTimerInterval)); @@ -201,7 +201,7 @@ void tst_QEventDispatcher::registerTimer() return; // check that all 3 are present in the eventDispatcher's registeredTimer() list - QCOMPARE(timers.registeredTimers().count(), 3); + QCOMPARE(timers.registeredTimers().size(), 3); QVERIFY(timers.foundPrecise()); QVERIFY(timers.foundCoarse()); QVERIFY(timers.foundVeryCoarse()); @@ -236,7 +236,7 @@ void tst_QEventDispatcher::registerTimer() timers.unregister(timers.preciseTimerId()); if (QTest::currentTestFailed()) return; - QCOMPARE(timers.registeredTimers().count(), 2); + QCOMPARE(timers.registeredTimers().size(), 2); QVERIFY(!timers.foundPrecise()); QVERIFY(timers.foundCoarse()); QVERIFY(timers.foundVeryCoarse()); @@ -260,7 +260,7 @@ void tst_QEventDispatcher::registerTimer() timers.unregister(timers.coarseTimerId()); if (QTest::currentTestFailed()) return; - QCOMPARE(timers.registeredTimers().count(), 1); + QCOMPARE(timers.registeredTimers().size(), 1); QVERIFY(!timers.foundPrecise()); QVERIFY(!timers.foundCoarse()); QVERIFY(timers.foundVeryCoarse()); diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 74b08601b7..16437d39f9 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -174,8 +174,8 @@ void tst_QEventLoop::processEvents() // process posted events, QEventLoop::processEvents() should return // true QVERIFY(eventLoop.processEvents()); - QCOMPARE(aboutToBlockSpy.count(), 0); - QCOMPARE(awakeSpy.count(), 1); + QCOMPARE(aboutToBlockSpy.size(), 0); + QCOMPARE(awakeSpy.size(), 1); // allow any session manager to complete its handshake, so that // there are no pending events left. This tests that we are able @@ -196,8 +196,8 @@ void tst_QEventLoop::processEvents() // processEvents is entered. There is no guarantee that that the // processEvents call actually blocked, since the OS may introduce // native events at any time. - QVERIFY(awakeSpy.count() > 0); - QVERIFY(awakeSpy.count() >= aboutToBlockSpy.count()); + QVERIFY(awakeSpy.size() > 0); + QVERIFY(awakeSpy.size() >= aboutToBlockSpy.size()); killTimer(timerId); } @@ -240,7 +240,7 @@ void tst_QEventLoop::exec() QVERIFY(spy.isValid()); thread.cond.wakeOne(); thread.cond.wait(&thread.mutex); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); int v = thread.result1; QCOMPARE(v, 0); @@ -249,7 +249,7 @@ void tst_QEventLoop::exec() thread.cond.wakeOne(); thread.mutex.unlock(); thread.wait(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); v = thread.result2; QCOMPARE(v, -1); } @@ -307,7 +307,7 @@ void tst_QEventLoop::wakeUp() QTimer::singleShot(1000, &eventLoop, SLOT(quit())); (void) eventLoop.exec(); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); thread.quit(); (void) eventLoop.exec(); diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 36f792ec8a..fbf9fb8d6e 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1498,8 +1498,8 @@ void tst_QMetaObjectBuilder::usage_signal() QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged); testObject->emitIntPropChanged(); - QCOMPARE(propChangedSpy.count(), 1); - QCOMPARE(propChangedSpy.at(0).count(), 1); + QCOMPARE(propChangedSpy.size(), 1); + QCOMPARE(propChangedSpy.at(0).size(), 1); QCOMPARE(propChangedSpy.at(0).at(0).toInt(), testObject->intProp()); } @@ -1514,7 +1514,7 @@ void tst_QMetaObjectBuilder::usage_property() QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged); QVERIFY(testObject->intProp() != 123); testObject->setProperty("intProp", 123); - QCOMPARE(propChangedSpy.count(), 1); + QCOMPARE(propChangedSpy.size(), 1); prop = testObject->property("intProp"); QCOMPARE(prop.metaType(), QMetaType(QMetaType::Int)); QCOMPARE(prop.toInt(), 123); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 652065a6e5..364955c7b3 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -525,14 +525,14 @@ void tst_QMetaType::properties() QCOMPARE(v.typeName(), "QVariantList"); QList<QVariant> values = v.toList(); - QCOMPARE(values.count(), 2); + QCOMPARE(values.size(), 2); QCOMPARE(values.at(0).toInt(), 42); values << 43 << "world"; QVERIFY(setProperty("prop", values)); v = property("prop"); - QCOMPARE(v.toList().count(), 4); + QCOMPARE(v.toList().size(), 4); } void tst_QMetaType::normalizedTypes() diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp index 03b07c41ec..6bf00ff57e 100644 --- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp +++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp @@ -71,8 +71,8 @@ void tst_QMimeData::data() const // set text, verify mimeData.setData("text/plain", "pirates"); QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); - QCOMPARE(mimeData.data("text/html").length(), 0); - QCOMPARE(mimeData.data("text/markdown").length(), 0); + QCOMPARE(mimeData.data("text/html").size(), 0); + QCOMPARE(mimeData.data("text/markdown").size(), 0); // html time mimeData.setData("text/html", "ninjas"); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 107299e983..47cc30bd04 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -960,7 +960,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed() QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(signal1()), (ReceiverObject *)&r, SLOT(slot1()))); } - QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.size(), 1); QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); s.disconnectedSignals.clear(); @@ -971,7 +971,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed() (ReceiverObject *)&r, SLOT(slot3()))); } - QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.size(), 1); QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal3)); s.disconnectedSignals.clear(); @@ -981,7 +981,7 @@ void tst_QObject::disconnectNotify_receiverDestroyed() QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(destroyed()), (ReceiverObject *)&r, SLOT(slot3()))); } - QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.size(), 1); QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&QObject::destroyed)); } @@ -996,10 +996,10 @@ void tst_QObject::disconnectNotify_metaObjConnection() QVERIFY(c); QVERIFY(QObject::disconnect(c)); - QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.size(), 1); QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); - QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.size(), 1); } } @@ -2125,18 +2125,18 @@ void tst_QObject::metamethod() QVERIFY(!(m.attributes() & QMetaMethod::Compatibility)); m = mobj->method(mobj->indexOfMethod("invoke1()")); - QCOMPARE(m.parameterNames().count(), 0); - QCOMPARE(m.parameterTypes().count(), 0); + QCOMPARE(m.parameterNames().size(), 0); + QCOMPARE(m.parameterTypes().size(), 0); m = mobj->method(mobj->indexOfMethod("invoke2(int)")); - QCOMPARE(m.parameterNames().count(), 1); - QCOMPARE(m.parameterTypes().count(), 1); + QCOMPARE(m.parameterNames().size(), 1); + QCOMPARE(m.parameterTypes().size(), 1); QCOMPARE(m.parameterTypes().at(0), QByteArray("int")); QVERIFY(m.parameterNames().at(0).isEmpty()); m = mobj->method(mobj->indexOfMethod("invoke3(int,int)")); - QCOMPARE(m.parameterNames().count(), 2); - QCOMPARE(m.parameterTypes().count(), 2); + QCOMPARE(m.parameterNames().size(), 2); + QCOMPARE(m.parameterTypes().size(), 2); QCOMPARE(m.parameterTypes().at(0), QByteArray("int")); QCOMPARE(m.parameterNames().at(0), QByteArray("hinz")); QCOMPARE(m.parameterTypes().at(1), QByteArray("int")); @@ -2951,22 +2951,22 @@ void tst_QObject::dynamicProperties() // set a dynamic property QVERIFY(!obj.setProperty("myuserproperty", "Hello")); - QCOMPARE(obj.changedDynamicProperties.count(), 1); + QCOMPARE(obj.changedDynamicProperties.size(), 1); QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty")); //check if there is no redundant DynamicPropertyChange events QVERIFY(!obj.setProperty("myuserproperty", "Hello")); - QCOMPARE(obj.changedDynamicProperties.count(), 1); + QCOMPARE(obj.changedDynamicProperties.size(), 1); QCOMPARE(obj.property("myuserproperty").type(), QVariant::String); QCOMPARE(obj.property("myuserproperty").toString(), QString("Hello")); - QCOMPARE(obj.dynamicPropertyNames().count(), 1); + QCOMPARE(obj.dynamicPropertyNames().size(), 1); QCOMPARE(obj.dynamicPropertyNames().first(), QByteArray("myuserproperty")); // change type of the dynamic property obj.changedDynamicProperties.clear(); QVERIFY(!obj.setProperty("myuserproperty", QByteArray("Hello"))); - QCOMPARE(obj.changedDynamicProperties.count(), 1); + QCOMPARE(obj.changedDynamicProperties.size(), 1); QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty")); QCOMPARE(obj.property("myuserproperty").type(), QVariant::ByteArray); QCOMPARE(obj.property("myuserproperty").toString(), QByteArray("Hello")); @@ -2975,7 +2975,7 @@ void tst_QObject::dynamicProperties() obj.changedDynamicProperties.clear(); QVERIFY(!obj.setProperty("myuserproperty", QVariant())); - QCOMPARE(obj.changedDynamicProperties.count(), 1); + QCOMPARE(obj.changedDynamicProperties.size(), 1); QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty")); obj.changedDynamicProperties.clear(); diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 93d2ac9783..216a10bd57 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -389,7 +389,7 @@ void tst_QProperty::changeHandler() } testProperty = 3; - QCOMPARE(recordedValues.count(), 2); + QCOMPARE(recordedValues.size(), 2); QCOMPARE(recordedValues.at(0), 1); QCOMPARE(recordedValues.at(1), 2); } @@ -432,7 +432,7 @@ void tst_QProperty::subscribe() } testProperty = 3; - QCOMPARE(recordedValues.count(), 3); + QCOMPARE(recordedValues.size(), 3); QCOMPARE(recordedValues.at(0), 42); QCOMPARE(recordedValues.at(1), 1); QCOMPARE(recordedValues.at(2), 2); @@ -867,7 +867,7 @@ void tst_QProperty::notifiedProperty() check(); instance.property.setValue(42); - QCOMPARE(instance.recordedValues.count(), 1); + QCOMPARE(instance.recordedValues.size(), 1); QCOMPARE(instance.recordedValues.at(0), 42); instance.recordedValues.clear(); check(); @@ -897,7 +897,7 @@ void tst_QProperty::notifiedProperty() subscribedCount = 0; QCOMPARE(instance.property.value(), 100); - QCOMPARE(instance.recordedValues.count(), 1); + QCOMPARE(instance.recordedValues.size(), 1); QCOMPARE(instance.recordedValues.at(0), 100); instance.recordedValues.clear(); check(); @@ -905,7 +905,7 @@ void tst_QProperty::notifiedProperty() injectedValue = 200; QCOMPARE(instance.property.value(), 200); - QCOMPARE(instance.recordedValues.count(), 1); + QCOMPARE(instance.recordedValues.size(), 1); QCOMPARE(instance.recordedValues.at(0), 200); instance.recordedValues.clear(); check(); @@ -914,7 +914,7 @@ void tst_QProperty::notifiedProperty() injectedValue = 400; QCOMPARE(instance.property.value(), 400); - QCOMPARE(instance.recordedValues.count(), 1); + QCOMPARE(instance.recordedValues.size(), 1); QCOMPARE(instance.recordedValues.at(0), 400); instance.recordedValues.clear(); check(); @@ -1153,12 +1153,12 @@ void tst_QProperty::qobjectBindableManualNotify() object.fooData.setValueBypassingBindings(42); // there is no change. QCOMPARE(fooChangeCount, 0); - QCOMPARE(fooChangedSpy.count(), 0); + QCOMPARE(fooChangedSpy.size(), 0); // Once we notify manually object.fooData.notify(); // observers are notified and the signal arrives. QCOMPARE(fooChangeCount, 1); - QCOMPARE(fooChangedSpy.count(), 1); + QCOMPARE(fooChangedSpy.size(), 1); // If we set a binding int i = 1; @@ -1167,16 +1167,16 @@ void tst_QProperty::qobjectBindableManualNotify() QCOMPARE(object.foo(), 1); // and the change and signal count are incremented. QCOMPARE(fooChangeCount, 2); - QCOMPARE(fooChangedSpy.count(), 2); + QCOMPARE(fooChangedSpy.size(), 2); // Changing a non-property won't trigger any notification. i = 2; QCOMPARE(fooChangeCount, 2); - QCOMPARE(fooChangedSpy.count(), 2); + QCOMPARE(fooChangedSpy.size(), 2); // Manually triggering the notification object.fooData.notify(); // increments the change count QCOMPARE(fooChangeCount, 3); - QCOMPARE(fooChangedSpy.count(), 3); + QCOMPARE(fooChangedSpy.size(), 3); // but doesn't actually cause a binding reevaluation. QCOMPARE(object.foo(), 1); } @@ -1559,7 +1559,7 @@ void tst_QProperty::compatPropertySignals() tester.setProp2(10); QCOMPARE(prop2Observer.value(), 10); - QCOMPARE(prop2Spy.count(), 1); + QCOMPARE(prop2Spy.size(), 1); QList<QVariant> arguments = prop2Spy.takeFirst(); QCOMPARE(arguments.size(), 1); QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int); @@ -1575,7 +1575,7 @@ void tst_QProperty::compatPropertySignals() tester.setProp3(5); QCOMPARE(prop3Observer.value(), 5); - QCOMPARE(prop3Spy.count(), 1); + QCOMPARE(prop3Spy.size(), 1); // Compat property with signal, default value, and custom setter. Signal has parameter. QProperty<int> prop4Observer; @@ -1587,7 +1587,7 @@ void tst_QProperty::compatPropertySignals() tester.setProp4(10); QCOMPARE(prop4Observer.value(), 10); - QCOMPARE(prop4Spy.count(), 1); + QCOMPARE(prop4Spy.size(), 1); arguments = prop4Spy.takeFirst(); QCOMPARE(arguments.size(), 1); QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int); @@ -1596,7 +1596,7 @@ void tst_QProperty::compatPropertySignals() tester.setProp4(42); QCOMPARE(prop4Observer.value(), 42); - QCOMPARE(prop4Spy.count(), 1); + QCOMPARE(prop4Spy.size(), 1); arguments = prop4Spy.takeFirst(); QCOMPARE(arguments.size(), 1); QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int); @@ -1605,7 +1605,7 @@ void tst_QProperty::compatPropertySignals() tester.setProp4(0); QCOMPARE(prop4Observer.value(), 42); - QCOMPARE(prop4Spy.count(), 1); + QCOMPARE(prop4Spy.size(), 1); arguments = prop4Spy.takeFirst(); QCOMPARE(arguments.size(), 1); QCOMPARE(arguments.at(0).metaType().id(), QMetaType::Int); @@ -1993,7 +1993,7 @@ void tst_QProperty::notify() testProperty = 4; QCOMPARE(value, 3); - QCOMPARE(recordedValues.count(), 2); + QCOMPARE(recordedValues.size(), 2); QCOMPARE(recordedValues.at(0), 1); QCOMPARE(recordedValues.at(1), 2); } diff --git a/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp b/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp index 968b45aae1..6dc4fde7ca 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/producerconsumer/main.cpp @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); QStringList arguments = app.arguments(); - if (app.arguments().count() != 2) { + if (app.arguments().size() != 2) { qWarning("Please call the helper with the function to call as argument"); return EXIT_FAILURE; } diff --git a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp index 63a33d73a0..3cd9357268 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp @@ -122,7 +122,7 @@ void tst_QSharedMemory::cleanup() jail.clear(); keys.append(EXISTING_SHARE); - for (int i = 0; i < keys.count(); ++i) { + for (int i = 0; i < keys.size(); ++i) { QSharedMemory sm(keys.at(i)); if (!sm.create(1024)) { //if (sm.error() != QSharedMemory::KeyError) diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 59ef20c6e4..c78650efba 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -309,8 +309,8 @@ void tst_QSocketNotifier::posixSockets() passive->waitForBytesWritten(5000); QTestEventLoop::instance().enterLoop(3); - QCOMPARE(readSpy.count(), 1); - QCOMPARE(errorSpy.count(), 0); + QCOMPARE(readSpy.size(), 1); + QCOMPARE(errorSpy.size(), 0); char buffer[100]; int r = qt_safe_read(posixSocket, buffer, 100); @@ -324,9 +324,9 @@ void tst_QSocketNotifier::posixSockets() qt_safe_write(posixSocket, "goodbye", 8); QTestEventLoop::instance().enterLoop(3); - QCOMPARE(readSpy.count(), 1); - QCOMPARE(writeSpy.count(), 1); - QCOMPARE(errorSpy.count(), 0); + QCOMPARE(readSpy.size(), 1); + QCOMPARE(writeSpy.size(), 1); + QCOMPARE(errorSpy.size(), 0); // Write notifier may have fired before the read notifier inside // QTcpSocket, give QTcpSocket a chance to see the incoming data @@ -387,7 +387,7 @@ void tst_QSocketNotifier::asyncMultipleDatagram() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); delete m_asyncSender; delete m_asyncReceiver; diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp index 979649d662..b2de1d764c 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/acquirerelease/main.cpp @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) QStringList arguments = app.arguments(); // binary name is not used here arguments.takeFirst(); - if (arguments.count() < 1) { + if (arguments.size() < 1) { qWarning("Please call the helper with the function to call as argument"); return EXIT_FAILURE; } @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) if (function == QLatin1String("acquire")) { int count = 1; bool ok = true; - if (arguments.count()) + if (arguments.size()) count = arguments.takeFirst().toInt(&ok); if (!ok) count = 1; diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp index e2f557b698..4435256d97 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp @@ -189,7 +189,7 @@ void tst_QSystemSemaphore::processes() QList<QString> scripts(processes, "acquirerelease"); QList<QProcess*> consumers; - for (int i = 0; i < scripts.count(); ++i) { + for (int i = 0; i < scripts.size(); ++i) { QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); consumers.append(p); diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 03a6f1b5aa..15e08a50a2 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -84,7 +84,7 @@ void tst_QTimer::zeroTimer() // Pass timeout to work round glib issue, see QTBUG-84291. QCoreApplication::processEvents(QEventLoop::AllEvents, INT_MAX); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); } void tst_QTimer::singleShotTimeout() @@ -98,9 +98,9 @@ void tst_QTimer::singleShotTimeout() timer.start(100); QVERIFY(timeoutSpy.wait(500)); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); QTest::qWait(500); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); } #define TIMEOUT_TIMEOUT 200 @@ -111,12 +111,12 @@ void tst_QTimer::timeout() QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.start(100); - QCOMPARE(timeoutSpy.count(), 0); + QCOMPARE(timeoutSpy.size(), 0); - QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 0, TIMEOUT_TIMEOUT); - int oldCount = timeoutSpy.count(); + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > 0, TIMEOUT_TIMEOUT); + int oldCount = timeoutSpy.size(); - QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > oldCount, TIMEOUT_TIMEOUT); + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > oldCount, TIMEOUT_TIMEOUT); } void tst_QTimer::remainingTime() @@ -259,24 +259,24 @@ void tst_QTimer::basic_chrono() QCoreApplication::processEvents(); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); timeoutSpy.clear(); timer.start(milliseconds(100)); - QCOMPARE(timeoutSpy.count(), 0); + QCOMPARE(timeoutSpy.size(), 0); QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); - QVERIFY(timeoutSpy.count() > 0); - int oldCount = timeoutSpy.count(); + QVERIFY(timeoutSpy.size() > 0); + int oldCount = timeoutSpy.size(); QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); - QVERIFY(timeoutSpy.count() > oldCount); + QVERIFY(timeoutSpy.size() > oldCount); timeoutSpy.clear(); timer.start(to_ms(microseconds(200000))); QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(200)); QTest::qWait(50); - QCOMPARE(timeoutSpy.count(), 0); + QCOMPARE(timeoutSpy.size(), 0); milliseconds rt = timer.remainingTimeAsDuration(); QVERIFY2(rt.count() >= 50 && rt.count() <= 200, qPrintable(QString::number(rt.count()))); @@ -285,9 +285,9 @@ void tst_QTimer::basic_chrono() timer.setSingleShot(true); timer.start(milliseconds(100)); QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); QTest::qWait(500); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); } void tst_QTimer::livelock_data() @@ -1001,7 +1001,7 @@ void tst_QTimer::postedEventsShouldNotStarveTimers() timer.start(); SlotRepeater slotRepeater; slotRepeater.repeatThisSlot(); - QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 5, 100); + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.size() > 5, 100); } struct DummyFunctor { @@ -1044,7 +1044,7 @@ void tst_QTimer::callOnTimeout() QTest::qWait(100); QCOMPARE(count, 2); - QCOMPARE(timeoutSpy.count(), 1); + QCOMPARE(timeoutSpy.size(), 1); // Test that connection is bound to context lifetime QVERIFY(connection); diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index 372a7a9db1..5e7a42d6da 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -98,7 +98,7 @@ void tst_QTranslator::load() file.open(QFile::ReadOnly); QByteArray data = file.readAll(); QTranslator tor; - QVERIFY(tor.load((const uchar *)data.constData(), data.length())); + QVERIFY(tor.load((const uchar *)data.constData(), data.size())); QCOMPARE(tor.isEmpty(), isEmpty); QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation); QCOMPARE(tor.filePath(), ""); @@ -331,7 +331,7 @@ void tst_QTranslator::dependencies() QFile file("dependencies_la.qm"); file.open(QFile::ReadOnly); QByteArray data = file.readAll(); - QVERIFY(tor.load((const uchar *)data.constData(), data.length())); + QVERIFY(tor.load((const uchar *)data.constData(), data.size())); QVERIFY(!tor.isEmpty()); QCOMPARE(tor.translate("QPushButton", "Hello world!"), QLatin1String("Hallo Welt!")); } diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 05808d3555..96aad8a26a 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -3067,57 +3067,57 @@ void tst_QVariant::convertIterables() const { QStringList list; list.append("Hello"); - QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count()); + QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size()); } { QByteArrayList list; list.append("Hello"); - QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count()); + QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size()); } { QVariantList list; list.append("World"); - QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count()); + QCOMPARE(QVariant::fromValue(list).value<QVariantList>().size(), list.size()); } { QMap<QString, int> map; map.insert("3", 4); - QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count()); - QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size()); + QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size()); map.insert("4", 5); - QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count()); - QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size()); + QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size()); } { QVariantMap map; map.insert("3", 4); - QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count()); - QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size()); + QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size()); map.insert("4", 5); - QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count()); - QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count()); + QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().size(), map.size()); + QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().size(), map.size()); } { QHash<QString, int> hash; hash.insert("3", 4); - QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count()); - QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size()); hash.insert("4", 5); - QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count()); - QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size()); } { QVariantHash hash; hash.insert("3", 4); - QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count()); - QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size()); hash.insert("4", 5); - QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count()); - QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().size(), hash.size()); + QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().size(), hash.size()); } } diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index fae26f4971..8c6bc73cdf 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -277,7 +277,7 @@ void tst_QMimeDatabase::mimeTypeForFileName() QVERIFY(mimes.isEmpty()); } else { QVERIFY2(!mimes.isEmpty(), msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData()); - QVERIFY2(mimes.count() == 1, msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData()); + QVERIFY2(mimes.size() == 1, msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData()); QCOMPARE(mimes.first().name(), expectedMimeType); } } @@ -328,7 +328,7 @@ void tst_QMimeDatabase::inheritance() const QMimeType directory = db.mimeTypeForName(QString::fromLatin1("inode/directory")); QVERIFY(directory.isValid()); - QCOMPARE(directory.parentMimeTypes().count(), 0); + QCOMPARE(directory.parentMimeTypes().size(), 0); QVERIFY(!directory.inherits(QLatin1String("application/octet-stream"))); // Check that text/x-patch knows that it inherits from text/plain (it says so explicitly) @@ -349,7 +349,7 @@ void tst_QMimeDatabase::inheritance() const QStringList shellParents = shellscript.parentMimeTypes(); QVERIFY(shellParents.contains(QLatin1String("text/plain"))); QVERIFY(shellParents.contains(QLatin1String("application/x-executable"))); - QCOMPARE(shellParents.count(), 2); // only the above two + QCOMPARE(shellParents.size(), 2); // only the above two const QStringList allShellAncestors = shellscript.allAncestors(); QVERIFY(allShellAncestors.contains(QLatin1String("text/plain"))); QVERIFY(allShellAncestors.contains(QLatin1String("application/x-executable"))); @@ -591,7 +591,7 @@ void tst_QMimeDatabase::allMimeTypes() QVERIFY(!lst.isEmpty()); // Hardcoding this is the only way to check both providers find the same number of mimetypes. - QCOMPARE(lst.count(), 851); + QCOMPARE(lst.size(), 851); foreach (const QMimeType &mime, lst) { const QString name = mime.name(); @@ -741,7 +741,7 @@ void tst_QMimeDatabase::findByFileName() //qDebug() << Q_FUNC_INFO << "mimeTypeForFile() returned" << resultMimeTypeName; const bool failed = resultMimeTypeName != mimeTypeName; - const bool shouldFail = (xFail.length() >= 1 && xFail.at(0) == QLatin1Char('x')); + const bool shouldFail = (xFail.size() >= 1 && xFail.at(0) == QLatin1Char('x')); if (shouldFail != failed) { // Results are ambiguous when multiple MIME types have the same glob // -> accept the current result if the found MIME type actually @@ -788,7 +788,7 @@ void tst_QMimeDatabase::findByData() QByteArray data = f.read(16384); const QString resultMimeTypeName = database.mimeTypeForData(data).name(); - if (xFail.length() >= 2 && xFail.at(1) == QLatin1Char('x')) { + if (xFail.size() >= 2 && xFail.at(1) == QLatin1Char('x')) { // Expected to fail QVERIFY2(resultMimeTypeName != mimeTypeName, qPrintable(resultMimeTypeName)); } else { @@ -819,7 +819,7 @@ void tst_QMimeDatabase::findByFile() QMimeDatabase database; const QString resultMimeTypeName = database.mimeTypeForFile(filePath).name(); //qDebug() << Q_FUNC_INFO << filePath << "->" << resultMimeTypeName; - if (xFail.length() >= 3 && xFail.at(2) == QLatin1Char('x')) { + if (xFail.size() >= 3 && xFail.at(2) == QLatin1Char('x')) { // Expected to fail QVERIFY2(resultMimeTypeName != mimeTypeName, qPrintable(resultMimeTypeName)); } else { diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 721ac27020..6d68bdf3e0 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -376,14 +376,14 @@ void tst_QPluginLoader::deleteinstanceOnUnload() QVERIFY(spy2.isValid()); if (pass == 0) { QCOMPARE(loader2.unload(), false); // refcount not reached 0, not really unloaded - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); + QCOMPARE(spy1.size(), 0); + QCOMPARE(spy2.size(), 0); } QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok")); QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok")); QVERIFY(loader1.unload()); // refcount reached 0, did really unload - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 1); + QCOMPARE(spy2.size(), 1); } } @@ -969,7 +969,7 @@ void tst_QPluginLoader::reloadPlugin() QSignalSpy spy(loader.instance(), &QObject::destroyed); QVERIFY(spy.isValid()); QVERIFY(loader.unload()); // refcount reached 0, did really unload - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // reload plugin QVERIFY(loader.load()); diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index eb0ce46502..c3170dd354 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -372,13 +372,13 @@ public: void tst_QUuid::threadUniqueness() { QList<UuidThread *> threads(qMax(2, QThread::idealThreadCount())); - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i] = new UuidThread; - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->start(); - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) QVERIFY(threads[i]->wait(1000)); - for (int i = 1; i < threads.count(); ++i) + for (int i = 1; i < threads.size(); ++i) QVERIFY(threads[0]->uuid != threads[i]->uuid); qDeleteAll(threads); } diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp index 5651cc3987..52c4e6cfbe 100644 --- a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp +++ b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp @@ -81,7 +81,7 @@ void encodeVariant(QCborStreamWriter &writer, const QVariant &v) list = v.value<IndeterminateLengthArray>(); writer.startArray(); } else { - writer.startArray(list.length()); + writer.startArray(list.size()); } for (const QVariant &v2 : qAsConst(list)) encodeVariant(writer, v2); @@ -94,7 +94,7 @@ void encodeVariant(QCborStreamWriter &writer, const QVariant &v) map = v.value<IndeterminateLengthMap>(); writer.startMap(); } else { - writer.startMap(map.length()); + writer.startMap(map.size()); } for (auto pair : qAsConst(map)) { encodeVariant(writer, pair.first); diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 296f491724..a203861e30 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -960,10 +960,10 @@ static void QBitArrayData(QBitArray *b, int index) case 18: filler = "1111111111111111111111111111111111111111111111111111111111111111"; break; } - b->resize(filler.length()); + b->resize(filler.size()); b->fill(0); // reset all bits to zero - for (int i = 0; i < filler.length(); ++i) { + for (int i = 0; i < filler.size(); ++i) { if (filler.at(i) == '1') b->setBit(i, true); } diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index cf1049ab4f..53b5810451 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -1413,7 +1413,7 @@ void tst_QTextStream::pos3LargeFile() // NOTE: The unusual spacing is to ensure non-1-character whitespace. QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n"; // Approximate 50kb text file - const int NbLines = (50*1024) / lineString.length() + 1; + const int NbLines = (50*1024) / lineString.size() + 1; for (int line = 0; line < NbLines; ++line) out << lineString; // File is automatically flushed and closed on destruction. diff --git a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp index a01b097576..3d3b724599 100644 --- a/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp +++ b/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp @@ -91,12 +91,12 @@ void tst_QByteArrayMatcher::interface() QCOMPARE(matcher5.indexIn(haystack), 42); QCOMPARE(matcher6.indexIn(haystack), 42); - QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length()), 42); + QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size()), 42); QCOMPARE(matcher1.indexIn(haystack, 43), 84); - QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 43), 84); + QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 43), 84); QCOMPARE(matcher1.indexIn(haystack, 85), -1); - QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 85), -1); + QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.size(), 85), -1); QByteArrayMatcher matcher7(QByteArray("123")); QCOMPARE(matcher7.indexIn(haystack), 6); diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp index 725a7e0d72..9f887bb59f 100644 --- a/tests/auto/corelib/text/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp @@ -797,7 +797,7 @@ void tst_QChar::normalization_data() line = line.trimmed(); if (line.endsWith(';')) - line.truncate(line.length()-1); + line.truncate(line.size()-1); QList<QByteArray> l = line.split(';'); diff --git a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp index 89e8ae89b1..58d2fab09f 100644 --- a/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/text/qstringlist/tst_qstringlist.cpp @@ -174,12 +174,12 @@ void tst_QStringList::sort() list4 << "alpha" << "beta" << "BETA" << "epsilon" << "Gamma" << "gAmma" << "gamma"; // with this list, case insensitive sorting can give more than one permutation for "equivalent" // elements; so we check that the sort gave the formally correct result (list[i] <= list[i+1]) - for (int i = 0; i < list4.count() - 1; ++i) + for (int i = 0; i < list4.size() - 1; ++i) QVERIFY2(QString::compare(list4.at(i), list4.at(i + 1), Qt::CaseInsensitive) <= 0, qPrintable(QString("index %1 failed").arg(i))); // additional checks QCOMPARE(list4.at(0), QString("alpha")); QVERIFY(list4.indexOf("epsilon") > 0); - QVERIFY(list4.indexOf("epsilon") < (list4.count() - 1)); + QVERIFY(list4.indexOf("epsilon") < (list4.size() - 1)); } void tst_QStringList::replaceInStrings() diff --git a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 0b29740e53..ea7d2f6982 100644 --- a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -186,7 +186,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea QVERIFY(boundaryFinder.boundaryReasons() == QTextBoundaryFinder::NotAtBoundary); // test boundaryReasons() - for (int i = 0; i <= testString.length(); ++i) { + for (int i = 0; i <= testString.size(); ++i) { boundaryFinder.setPosition(i); QCOMPARE(!!(boundaryFinder.boundaryReasons() & reasons), expectedBreakPositions.contains(i)); } @@ -768,7 +768,7 @@ void tst_QTextBoundaryFinder::emptyText() void tst_QTextBoundaryFinder::fastConstructor() { QString text("Hello World"); - QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.length(), /*buffer*/0, /*buffer size*/0); + QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text.constData(), text.size(), /*buffer*/0, /*buffer size*/0); QCOMPARE(finder.position(), 0); QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem); @@ -782,7 +782,7 @@ void tst_QTextBoundaryFinder::fastConstructor() QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::StartOfItem); finder.toNextBoundary(); - QCOMPARE(finder.position(), text.length()); + QCOMPARE(finder.position(), text.size()); QVERIFY(finder.boundaryReasons() & QTextBoundaryFinder::EndOfItem); finder.toNextBoundary(); diff --git a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp index 15aec7d63e..5232a62778 100644 --- a/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp +++ b/tests/auto/corelib/text/qunicodetools/tst_qunicodetools.cpp @@ -47,7 +47,7 @@ static void verifyCharClassPattern(QString str, qulonglong pattern, QCharAttributes cleared; memset(&cleared, 0, sizeof(QCharAttributes)); QList<QCharAttributes> attributes(str.size() + 1, cleared); - QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.count(), + QUnicodeTools::initCharAttributes(str, scriptItems.data(), scriptItems.size(), attributes.data(), type); qulonglong bit = 1ull << str.size(); diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp index 5f1e26ad02..fe84ec1ae4 100644 --- a/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp +++ b/tests/auto/corelib/thread/qfuturesynchronizer/tst_qfuturesynchronizer.cpp @@ -82,7 +82,7 @@ void tst_QFutureSynchronizer::futures() synchronizer.addFuture(future); } - QCOMPARE(futures.count(), synchronizer.futures().count()); + QCOMPARE(futures.size(), synchronizer.futures().size()); } void tst_QFutureSynchronizer::setFuture() diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index e9eb7b24b0..645e22602e 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -238,8 +238,8 @@ void tst_QFutureWatcher::cancelAndFinish() fi.cancelAndFinish(); // The signals should be emitted only once - QTRY_COMPARE(canceledSpy.count(), 1); - QTRY_COMPARE(finishedSpy.count(), 1); + QTRY_COMPARE(canceledSpy.size(), 1); + QTRY_COMPARE(finishedSpy.size(), 1); } class IntTask : public RunFunctionTaskBase<int> @@ -349,21 +349,21 @@ void tst_QFutureWatcher::futureSignals() const int progress = 1; a.setProgressValue(progress); - QTRY_COMPARE(progressSpy.count(), 2); + QTRY_COMPARE(progressSpy.size(), 2); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); const int result = 10; a.reportResult(&result); QVERIFY(resultReadySpy.wait()); - QCOMPARE(resultReadySpy.count(), 1); + QCOMPARE(resultReadySpy.size(), 1); a.reportFinished(&result); - QTRY_COMPARE(resultReadySpy.count(), 2); + QTRY_COMPARE(resultReadySpy.size(), 2); QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 0); // check the index QCOMPARE(resultReadySpy.takeFirst().at(0).toInt(), 1); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(finishedSpy.size(), 1); } } @@ -402,10 +402,10 @@ void tst_QFutureWatcher::watchFinishedFuture() watcher.setFuture(f); QVERIFY(finishedSpy.wait()); - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(resultReadySpy.count(), 1); - QCOMPARE(canceledSpy.count(), 0); + QCOMPARE(startedSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(resultReadySpy.size(), 1); + QCOMPARE(canceledSpy.size(), 0); } void tst_QFutureWatcher::watchCanceledFuture() @@ -436,10 +436,10 @@ void tst_QFutureWatcher::watchCanceledFuture() watcher.setFuture(f); QVERIFY(finishedSpy.wait()); - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(resultReadySpy.count(), 0); - QCOMPARE(canceledSpy.count(), 1); + QCOMPARE(startedSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(resultReadySpy.size(), 0); + QCOMPARE(canceledSpy.size(), 1); } void tst_QFutureWatcher::disconnectRunningFuture() @@ -462,17 +462,17 @@ void tst_QFutureWatcher::disconnectRunningFuture() const int result = 10; a.reportResult(&result); QVERIFY(resultReadySpy.wait()); - QCOMPARE(resultReadySpy.count(), 1); + QCOMPARE(resultReadySpy.size(), 1); delete watcher; a.reportResult(&result); QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 1); + QCOMPARE(resultReadySpy.size(), 1); a.reportFinished(&result); QTest::qWait(10); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); } const int maxProgress = 100000; @@ -672,14 +672,14 @@ void tst_QFutureWatcher::changeFuture() watcher.setFuture(b); // But oh no! we're switching to another future QTest::qWait(10); // before the event gets delivered. - QCOMPARE(resultReadySpy.count(), 0); + QCOMPARE(resultReadySpy.size(), 0); watcher.setFuture(a); watcher.setFuture(b); watcher.setFuture(a); // setting it back gets us one event, not two. QVERIFY(resultReadySpy.wait()); - QCOMPARE(resultReadySpy.count(), 1); + QCOMPARE(resultReadySpy.size(), 1); } // Test that events aren't delivered from canceled futures @@ -707,7 +707,7 @@ void tst_QFutureWatcher::cancelEvents() QVERIFY(finishedSpy.wait()); - QCOMPARE(resultReadySpy.count(), 0); + QCOMPARE(resultReadySpy.size(), 0); } #if QT_DEPRECATED_SINCE(6, 0) @@ -734,14 +734,14 @@ void tst_QFutureWatcher::pauseEvents() watcher.setFuture(iface.future()); watcher.pause(); - QTRY_COMPARE(pauseSpy.count(), 1); + QTRY_COMPARE(pauseSpy.size(), 1); int value = 0; iface.reportFinished(&value); // A result is reported, although the watcher is paused. // The corresponding event should be also reported. - QTRY_COMPARE(resultReadySpy.count(), 1); + QTRY_COMPARE(resultReadySpy.size(), 1); watcher.resume(); } @@ -769,7 +769,7 @@ void tst_QFutureWatcher::pauseEvents() a.resume(); // should give us no results. QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 0); + QCOMPARE(resultReadySpy.size(), 0); } } @@ -789,23 +789,23 @@ void tst_QFutureWatcher::pausedSuspendedOrder() bool pausedBeforeSuspended = false; bool notSuspendedBeforePaused = false; connect(&watcher, &QFutureWatcher<void>::paused, - [&] { notSuspendedBeforePaused = (suspendedSpy.count() == 0); }); + [&] { notSuspendedBeforePaused = (suspendedSpy.size() == 0); }); connect(&watcher, &QFutureWatcher<void>::suspended, - [&] { pausedBeforeSuspended = (pausedSpy.count() == 1); }); + [&] { pausedBeforeSuspended = (pausedSpy.size() == 1); }); watcher.setFuture(iface.future()); iface.reportSuspended(); // Make sure reportPaused() is ignored if the state is not paused pausedSpy.wait(100); - QCOMPARE(pausedSpy.count(), 0); - QCOMPARE(suspendedSpy.count(), 0); + QCOMPARE(pausedSpy.size(), 0); + QCOMPARE(suspendedSpy.size(), 0); iface.setPaused(true); iface.reportSuspended(); - QTRY_COMPARE(suspendedSpy.count(), 1); - QCOMPARE(pausedSpy.count(), 1); + QTRY_COMPARE(suspendedSpy.size(), 1); + QCOMPARE(pausedSpy.size(), 1); QVERIFY(notSuspendedBeforePaused); QVERIFY(pausedBeforeSuspended); @@ -836,14 +836,14 @@ void tst_QFutureWatcher::suspendEvents() watcher.setFuture(iface.future()); watcher.suspend(); - QTRY_COMPARE(suspendingSpy.count(), 1); + QTRY_COMPARE(suspendingSpy.size(), 1); int value = 0; iface.reportFinished(&value); // A result is reported, although the watcher is paused. // The corresponding event should be also reported. - QTRY_COMPARE(resultReadySpy.count(), 1); + QTRY_COMPARE(resultReadySpy.size(), 1); watcher.resume(); } @@ -872,7 +872,7 @@ void tst_QFutureWatcher::suspendEvents() a.resume(); // should give us no results. QTest::qWait(10); - QCOMPARE(resultReadySpy.count(), 0); + QCOMPARE(resultReadySpy.size(), 0); } } @@ -910,29 +910,29 @@ QT_WARNING_POP watcher.suspend(); watcher.suspend(); - QTRY_COMPARE(suspendedSpy.count(), 1); // suspended() should be emitted only once - QCOMPARE(suspendingSpy.count(), 2); // suspending() is emitted as many times as requested + QTRY_COMPARE(suspendedSpy.size(), 1); // suspended() should be emitted only once + QCOMPARE(suspendingSpy.size(), 2); // suspending() is emitted as many times as requested #if QT_DEPRECATED_SINCE(6, 0) - QCOMPARE(pausedSpy.count(), 2); // paused() is emitted as many times as requested + QCOMPARE(pausedSpy.size(), 2); // paused() is emitted as many times as requested #endif // Make sure QFutureWatcher::resultReadyAt() is emitted only for already started threads. - const auto resultReadyAfterPaused = resultReadySpy.count(); + const auto resultReadyAfterPaused = resultReadySpy.size(); QCOMPARE(resultReadyAfterPaused, count); // Make sure no more results are reported before resuming. QThread::msleep(200); - QCOMPARE(resultReadyAfterPaused, resultReadySpy.count()); + QCOMPARE(resultReadyAfterPaused, resultReadySpy.size()); resultReadySpy.clear(); watcher.resume(); - QTRY_COMPARE(finishedSpy.count(), 1); + QTRY_COMPARE(finishedSpy.size(), 1); // Make sure that no more suspended() signals have been emitted. - QCOMPARE(suspendedSpy.count(), 1); + QCOMPARE(suspendedSpy.size(), 1); // Make sure the rest of results were reported after resume. - QCOMPARE(resultReadySpy.count(), numValues - resultReadyAfterPaused); + QCOMPARE(resultReadySpy.size(), numValues - resultReadyAfterPaused); } void tst_QFutureWatcher::suspendedEventsOrder() @@ -951,23 +951,23 @@ void tst_QFutureWatcher::suspendedEventsOrder() bool suspendingBeforeSuspended = false; bool notSuspendedBeforeSuspending = false; connect(&watcher, &QFutureWatcher<void>::suspending, - [&] { notSuspendedBeforeSuspending = (suspendedSpy.count() == 0); }); + [&] { notSuspendedBeforeSuspending = (suspendedSpy.size() == 0); }); connect(&watcher, &QFutureWatcher<void>::suspended, - [&] { suspendingBeforeSuspended = (suspendingSpy.count() == 1); }); + [&] { suspendingBeforeSuspended = (suspendingSpy.size() == 1); }); watcher.setFuture(iface.future()); iface.reportSuspended(); // Make sure reportPaused() is ignored if the state is not paused suspendingSpy.wait(100); - QCOMPARE(suspendingSpy.count(), 0); - QCOMPARE(suspendedSpy.count(), 0); + QCOMPARE(suspendingSpy.size(), 0); + QCOMPARE(suspendedSpy.size(), 0); iface.setSuspended(true); iface.reportSuspended(); - QTRY_COMPARE(suspendedSpy.count(), 1); - QCOMPARE(suspendingSpy.count(), 1); + QTRY_COMPARE(suspendedSpy.size(), 1); + QCOMPARE(suspendingSpy.size(), 1); QVERIFY(notSuspendedBeforeSuspending); QVERIFY(suspendingBeforeSuspended); @@ -997,7 +997,7 @@ void tst_QFutureWatcher::throttling() QVERIFY(iface.isThrottled()); - QTRY_COMPARE(resultSpy.count(), resultCount); // Process the results + QTRY_COMPARE(resultSpy.size(), resultCount); // Process the results QVERIFY(!iface.isThrottled()); diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index b98fc0dbc8..788d5441a3 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -220,8 +220,8 @@ void tst_QTimeZone::createTest() tran.daylightTimeOffset = 3600; expected << tran; QTimeZone::OffsetDataList result = tz.transitions(janPrev, jan); - QCOMPARE(result.count(), expected.count()); - for (int i = 0; i < expected.count(); ++i) { + QCOMPARE(result.size(), expected.size()); + for (int i = 0; i < expected.size(); ++i) { QCOMPARE(result.at(i).atUtc, expected.at(i).atUtc); QCOMPARE(result.at(i).offsetFromUtc, expected.at(i).offsetFromUtc); QCOMPARE(result.at(i).standardTimeOffset, expected.at(i).standardTimeOffset); @@ -559,7 +559,7 @@ void tst_QTimeZone::specificTransition() QSKIP("Missing time-zone data"); QTimeZone::OffsetDataList transits = timeZone.transitions(start.startOfDay(timeZone), stop.endOfDay(timeZone)); - QCOMPARE(transits.length(), count); + QCOMPARE(transits.size(), count); if (count) { const QTimeZone::OffsetData &transition = transits.at(0); QCOMPARE(transition.offsetFromUtc, offset); @@ -1538,8 +1538,8 @@ void tst_QTimeZone::testCetPrivate(const QTimeZonePrivate &tzp) tran.daylightTimeOffset = 0; expected << tran; QTimeZonePrivate::DataList result = tzp.transitions(prev, std); - QCOMPARE(result.count(), expected.count()); - for (int i = 0; i < expected.count(); ++i) { + QCOMPARE(result.size(), expected.size()); + for (int i = 0; i < expected.size(); ++i) { QCOMPARE(QDateTime::fromMSecsSinceEpoch(result.at(i).atMSecsSinceEpoch, Qt::OffsetFromUTC, 3600), QDateTime::fromMSecsSinceEpoch(expected.at(i).atMSecsSinceEpoch, diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 4b2d3b56b2..97f0c142f2 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -684,7 +684,7 @@ QT_WARNING_POP list.insert(0, "atzero"); QCOMPARE(list.at(0), QString("atzero")); - int listCount = list.count(); + int listCount = list.size(); list.insert(listCount, "atcount"); QCOMPARE(list.at(listCount), QString("atcount")); } @@ -2018,8 +2018,8 @@ void tst_Collections::qstring() s = "ascii"; s += QChar((uchar) 0xb0); QVERIFY(s.toUtf8() != s.toLatin1()); - QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0); - QCOMPARE(s.left(s.length()-1), QLatin1String("ascii")); + QCOMPARE(s[s.size()-1].unicode(), (ushort)0xb0); + QCOMPARE(s.left(s.size()-1), QLatin1String("ascii")); QVERIFY(s == QString::fromUtf8(s.toUtf8().constData())); @@ -2071,7 +2071,7 @@ void tst_Collections::qstring() QString str = "Hello"; - QString cstr = QString::fromRawData(str.unicode(), str.length()); + QString cstr = QString::fromRawData(str.unicode(), str.size()); QCOMPARE(str, QLatin1String("Hello")); QCOMPARE(cstr, QLatin1String("Hello")); cstr.clear(); @@ -2693,7 +2693,7 @@ void tst_Collections::vector_stl() QFETCH(QStringList, elements); QList<QString> vector; - for (int i = 0; i < elements.count(); ++i) + for (int i = 0; i < elements.size(); ++i) vector << elements.at(i); #if QT_VERSION < QT_VERSION_CHECK(6,0,0) @@ -2728,7 +2728,7 @@ void tst_Collections::list_stl() QFETCH(QStringList, elements); QList<QString> list; - for (int i = 0; i < elements.count(); ++i) + for (int i = 0; i < elements.size(); ++i) list << elements.at(i); #if QT_VERSION < QT_VERSION_CHECK(6,0,0) @@ -2821,7 +2821,7 @@ void instantiateContainer() container.clear(); container.contains(value); - container.count(); + container.size(); container.empty(); container.isEmpty(); container.size(); @@ -3246,7 +3246,7 @@ template<template<class> class C> void QTBUG13079_collectionInsideCollectionImpl QCOMPARE(nodeList.first().s, QString::fromLatin1("child")); nodeList = nodeList.first().children; - QCOMPARE(nodeList.count(), 0); + QCOMPARE(nodeList.size(), 0); nodeList << QTBUG13079_Node<C>(); } @@ -3271,7 +3271,7 @@ template<template<class, class> class C> void QTBUG13079_collectionInsideCollect QCOMPARE(nodeMap[12].s, QString::fromLatin1("child")); nodeMap = nodeMap[12].children; - QCOMPARE(nodeMap.count(), 0); + QCOMPARE(nodeMap.size(), 0); nodeMap[42] = QTBUG13079_NodeAssoc<C>(); } @@ -3338,7 +3338,7 @@ void tst_Collections::QTBUG13079_collectionInsideCollection() QSet<QTBUG13079_Node<QSet> > nodeSet; nodeSet << QTBUG13079_Node<QSet>(); nodeSet = nodeSet.begin()->children; - QCOMPARE(nodeSet.count(), 0); + QCOMPARE(nodeSet.size(), 0); } QTBUG13079_collectionInsideCollectionAssocImpl<QMap>(); @@ -3360,7 +3360,7 @@ template<class Container> void foreach_test_arrays(const Container &container) set << val; i++; } - QCOMPARE(set.count(), container.count()); + QCOMPARE(set.size(), container.size()); //modify the container while iterating. Container c2 = container; @@ -3397,9 +3397,9 @@ void tst_Collections::foreach_2() varl2 << i; varl3 << i; } - QCOMPARE(varl1.count(), intlist.count()); - QCOMPARE(varl2.count(), intlist.count()); - QCOMPARE(varl3.count(), intlist.count()); + QCOMPARE(varl1.size(), intlist.size()); + QCOMPARE(varl2.size(), intlist.size()); + QCOMPARE(varl3.size(), intlist.size()); QVarLengthArray<QString> varl4; QVarLengthArray<QString, 3> varl5; @@ -3409,9 +3409,9 @@ void tst_Collections::foreach_2() varl5 << str; varl6 << str; } - QCOMPARE(varl4.count(), strlist.count()); - QCOMPARE(varl5.count(), strlist.count()); - QCOMPARE(varl6.count(), strlist.count()); + QCOMPARE(varl4.size(), strlist.size()); + QCOMPARE(varl5.size(), strlist.size()); + QCOMPARE(varl6.size(), strlist.size()); } struct IntOrString @@ -3441,8 +3441,8 @@ template<class Container> void insert_remove_loop_impl() t.insert(t.begin() + 2, T(IntOrString(7))); t.insert(t.begin() + 5, 3, T(IntOrString(8))); int expect1[] = { 4 , 1 , 7, 5 , 5 , 8, 8, 8, 6, 5, 2 , 3 }; - QCOMPARE(size_t(t.count()), sizeof(expect1)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect1)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect1[i]))); } @@ -3456,8 +3456,8 @@ template<class Container> void insert_remove_loop_impl() t.remove(7); t.remove(2, 3); int expect2[] = { 4 , 1 , 9, 8, 6, 5, 2 , 3 }; - QCOMPARE(size_t(t.count()), sizeof(expect2)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect2)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect2[i]))); } @@ -3469,16 +3469,16 @@ template<class Container> void insert_remove_loop_impl() } int expect3[] = { 1 , 9, 5, 3 }; - QCOMPARE(size_t(t.count()), sizeof(expect3)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect3)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect3[i]))); } t.erase(t.begin() + 1, t.end() - 1); int expect4[] = { 1 , 3 }; - QCOMPARE(size_t(t.count()), sizeof(expect4)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect4)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect4[i]))); } @@ -3495,8 +3495,8 @@ template<class Container> void insert_remove_loop_impl() int expect5[] = { 1, 1, 2, 3*3, 3, 3*3+1, 10, 11*11, 11, 11*11+1, 12 , 13*13, 13, 13*13+1, 14, 15*15, 15, 15*15+1, 16 , 17*17, 17, 17*17+1 ,18 , 19*19, 19, 19*19+1, 20, 21*21, 21, 21*21+1 }; - QCOMPARE(size_t(t.count()), sizeof(expect5)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect5)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect5[i]))); } @@ -3506,8 +3506,8 @@ template<class Container> void insert_remove_loop_impl() t.insert(2, 4, T(IntOrString(7))); int expect6[] = { 1, 2, 7, 7, 7, 7, 9, 9, 9, 9, 3, 4 }; - QCOMPARE(size_t(t.count()), sizeof(expect6)/sizeof(int)); - for (int i = 0; i < t.count(); i++) { + QCOMPARE(size_t(t.size()), sizeof(expect6)/sizeof(int)); + for (int i = 0; i < t.size(); i++) { QCOMPARE(t[i], T(IntOrString(expect6[i]))); } diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp index 3c80608217..2e6c94e8e0 100644 --- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp @@ -13,10 +13,10 @@ static QBitArray QStringToQBitArray(const QString &str) { QBitArray ba; - ba.resize(str.length()); + ba.resize(str.size()); int i; QChar tru('1'); - for (i = 0; i < str.length(); i++) + for (i = 0; i < str.size(); i++) { if (str.at(i) == tru) { @@ -144,6 +144,7 @@ void tst_QBitArray::countBits() } QCOMPARE(bits.size(), numBits); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size() QCOMPARE(bits.count(), numBits); QCOMPARE(bits.count(true), onBits); QCOMPARE(bits.count(false), numBits - onBits); @@ -495,7 +496,7 @@ void tst_QBitArray::datastream() bits.setBit(i); } - QCOMPARE(bits.count(), numBits); + QCOMPARE(bits.size(), numBits); QCOMPARE(bits.count(true), onBits); QCOMPARE(bits.count(false), numBits - onBits); @@ -510,7 +511,7 @@ void tst_QBitArray::datastream() QBitArray array1, array2, array3; stream2 >> array1 >> array2 >> array3; - QCOMPARE(array1.count(), numBits); + QCOMPARE(array1.size(), numBits); QCOMPARE(array1.count(true), onBits); QCOMPARE(array1.count(false), numBits - onBits); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index c2f6811d27..6252440232 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -503,7 +503,7 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes() QVERIFY(parser.addOption(forceShort)); QVERIFY(parser.parse(commandLine)); QCOMPARE(parser.optionNames(), expectedOptionNames); - for (int i = 0; i < expectedOptionValues.count(); ++i) + for (int i = 0; i < expectedOptionValues.size(); ++i) QCOMPARE(parser.value(parser.optionNames().at(i)), expectedOptionValues.at(i)); QCOMPARE(parser.unknownOptionNames(), QStringList()); } @@ -762,7 +762,7 @@ void tst_QCommandLineParser::testVeryLongOptionNames() output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif const QStringList lines = output.split('\n'); - const int last = lines.count() - 1; + const int last = lines.size() - 1; // Let's not compare everything, just the final parts. QCOMPARE(lines.at(last - 7), " cdefghijklmnopqrstuvwxyz"); QCOMPARE(lines.at(last - 6), " --looooooooooooong-option, --looooong-opt-alias <l Short description"); diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index 189b11107e..7a2cfffaea 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -51,21 +51,23 @@ void tst_QContiguousCache::empty() QContiguousCache<int> c(10); QCOMPARE(c.capacity(), 10); QCOMPARE(c.size(), 0); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size() QCOMPARE(c.count(), 0); QVERIFY(c.isEmpty()); c.append(1); - QCOMPARE(c.count(), 1); QCOMPARE(c.size(), 1); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): : We want to test count() and size() + QCOMPARE(c.count(), 1); QVERIFY(!c.isEmpty()); c.clear(); QCOMPARE(c.capacity(), 10); - QCOMPARE(c.count(), 0); + QCOMPARE(c.size(), 0); QVERIFY(c.isEmpty()); c.prepend(1); - QCOMPARE(c.count(), 1); + QCOMPARE(c.size(), 1); QVERIFY(!c.isEmpty()); c.clear(); - QCOMPARE(c.count(), 0); + QCOMPARE(c.size(), 0); QVERIFY(c.isEmpty()); QCOMPARE(c.capacity(), 10); } @@ -76,9 +78,9 @@ void tst_QContiguousCache::swap() c1.append(1); c1.swap(c2); QCOMPARE(c1.capacity(), 100); - QCOMPARE(c1.count(), 0 ); + QCOMPARE(c1.size(), 0 ); QCOMPARE(c2.capacity(), 10 ); - QCOMPARE(c2.count(), 1 ); + QCOMPARE(c2.size(), 1 ); } void tst_QContiguousCache::append_data() @@ -114,7 +116,7 @@ void tst_QContiguousCache::append() QCOMPARE(c.available(), qMax(qsizetype(0), cacheSize - i)); QCOMPARE(c.first(), qMax(qsizetype(1), i-cacheSize+1)); QCOMPARE(c.last(), i); - QCOMPARE(c.count(), qMin(i, cacheSize)); + QCOMPARE(c.size(), qMin(i, cacheSize)); QCOMPARE(c.isFull(), i >= cacheSize); i++; } @@ -127,7 +129,7 @@ void tst_QContiguousCache::append() // test taking from end until empty. for (j = 0; j < cacheSize; j++, i--) { QCOMPARE(c.takeLast(), i-1); - QCOMPARE(c.count(), cacheSize-j-1); + QCOMPARE(c.size(), cacheSize-j-1); QCOMPARE(c.available(), j+1); QVERIFY(!c.isFull()); QCOMPARE(c.isEmpty(), j==cacheSize-1); @@ -165,7 +167,7 @@ void tst_QContiguousCache::prepend() QCOMPARE(c.available(), qMax(0, cacheSize - i)); QCOMPARE(c.last(), qMax(1, i-cacheSize+1)); QCOMPARE(c.first(), i); - QCOMPARE(c.count(), qMin(i, cacheSize)); + QCOMPARE(c.size(), qMin(i, cacheSize)); QCOMPARE(c.isFull(), i >= cacheSize); i++; } @@ -178,7 +180,7 @@ void tst_QContiguousCache::prepend() // test taking from start until empty. for (j = 0; j < cacheSize; j++, i--) { QCOMPARE(c.takeFirst(), i-1); - QCOMPARE(c.count(), cacheSize-j-1); + QCOMPARE(c.size(), cacheSize-j-1); QCOMPARE(c.available(), j+1); QVERIFY(!c.isFull()); QCOMPARE(c.isEmpty(), j==cacheSize-1); @@ -298,7 +300,7 @@ void tst_QContiguousCache::setCapacity() for (i = 280; i < 310; ++i) contiguousCache.insert(i, i); QCOMPARE(contiguousCache.capacity(), 100); - QCOMPARE(contiguousCache.count(), 30); + QCOMPARE(contiguousCache.size(), 30); QCOMPARE(contiguousCache.firstIndex(), 280); QCOMPARE(contiguousCache.lastIndex(), 309); @@ -310,7 +312,7 @@ void tst_QContiguousCache::setCapacity() contiguousCache.setCapacity(150); QCOMPARE(contiguousCache.capacity(), 150); - QCOMPARE(contiguousCache.count(), 30); + QCOMPARE(contiguousCache.size(), 30); QCOMPARE(contiguousCache.firstIndex(), 280); QCOMPARE(contiguousCache.lastIndex(), 309); @@ -322,7 +324,7 @@ void tst_QContiguousCache::setCapacity() contiguousCache.setCapacity(20); QCOMPARE(contiguousCache.capacity(), 20); - QCOMPARE(contiguousCache.count(), 20); + QCOMPARE(contiguousCache.size(), 20); QCOMPARE(contiguousCache.firstIndex(), 290); QCOMPARE(contiguousCache.lastIndex(), 309); diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 4d1d846eb8..4989de521f 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -374,7 +374,7 @@ void tst_QEasingCurve::valueForProgress() // in theory the baseline should't have an error of more than 0.00005 due to how its rounded, // but due to FP imprecision, we have to adjust the error a bit more. const qreal errorBound = 0.00006; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100))); QVERIFY(error <= errorBound); @@ -583,9 +583,9 @@ static inline void setupBezierSpline(QEasingCurve *easingCurve, const QString &s points.append(point); } - QVERIFY(points.count() % 3 == 0); + QVERIFY(points.size() % 3 == 0); - for (int i = 0; i < points.count() / 3; i++) { + for (int i = 0; i < points.size() / 3; i++) { QPointF c1 = points.at(i * 3); QPointF c2 = points.at(i * 3 + 1); QPointF p1 = points.at(i * 3 + 2); @@ -603,7 +603,7 @@ void tst_QEasingCurve::bezierSpline() setupBezierSpline(&bezierEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = bezierEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); @@ -646,7 +646,7 @@ static inline void setupTCBSpline(QEasingCurve *easingCurve, const QString &stri foreach (const QString &str, pointStr) { QStringList coordStr = str.split(QLatin1Char(',')); - Q_ASSERT(coordStr.count() == 5); + Q_ASSERT(coordStr.size() == 5); QPointF point(coordStr.first().toDouble(), coordStr.at(1).toDouble()); qreal t = coordStr.at(2).toDouble(); qreal c = coordStr.at(3).toDouble(); @@ -665,7 +665,7 @@ void tst_QEasingCurve::tcbSpline() setupTCBSpline(&tcbEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = tcbEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); diff --git a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp index f57abbf156..112a393136 100644 --- a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp +++ b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp @@ -682,7 +682,7 @@ void tst_QFlatMap::viewIterators() }); auto it = keys.begin(); QCOMPARE(*it, "kaksi"); - QCOMPARE(it->length(), 5); + QCOMPARE(it->size(), 5); ++it; QCOMPARE(*it, "kolme"); it++; @@ -703,7 +703,7 @@ void tst_QFlatMap::viewIterators() }); auto it = values.begin(); QCOMPARE(*it, "twee"); - QCOMPARE(it->length(), 4); + QCOMPARE(it->size(), 4); ++it; QCOMPARE(*it, "dree"); it++; diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 1b544944d8..27f63e8778 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -168,13 +168,13 @@ void tst_QHash::count() { MyMap map; MyMap map2( map ); - QCOMPARE( map.count(), 0 ); - QCOMPARE( map2.count(), 0 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 0 ); QCOMPARE( MyClass::count, 0 ); // detach map2["Hallo"] = MyClass( "Fritz" ); - QCOMPARE( map.count(), 0 ); - QCOMPARE( map2.count(), 1 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 1 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 1 ); #endif @@ -184,11 +184,11 @@ void tst_QHash::count() { typedef QHash<QString, MyClass> Map; Map map; - QCOMPARE( map.count(), 0); + QCOMPARE( map.size(), 0); map.insert( "Torben", MyClass("Weis") ); - QCOMPARE( map.count(), 1 ); + QCOMPARE( map.size(), 1 ); map.insert( "Claudia", MyClass("Sorg") ); - QCOMPARE( map.count(), 2 ); + QCOMPARE( map.size(), 2 ); map.insert( "Lars", MyClass("Linzbach") ); map.insert( "Matthias", MyClass("Ettrich") ); map.insert( "Sue", MyClass("Paludo") ); @@ -196,7 +196,7 @@ void tst_QHash::count() map.insert( "Haavard", MyClass("Nord") ); map.insert( "Arnt", MyClass("Gulbrandsen") ); map.insert( "Paul", MyClass("Tvete") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); map.insert( "Paul", MyClass("Tvete 1") ); map.insert( "Paul", MyClass("Tvete 2") ); map.insert( "Paul", MyClass("Tvete 3") ); @@ -204,68 +204,68 @@ void tst_QHash::count() map.insert( "Paul", MyClass("Tvete 5") ); map.insert( "Paul", MyClass("Tvete 6") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif Map map2( map ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); - QVERIFY( map.count() == 9 ); + QVERIFY( map2.size() == 10 ); + QVERIFY( map.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); + QVERIFY( map2.size() == 10 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map.remove( "Lars" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif map.remove( "Mist" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif @@ -279,22 +279,22 @@ void tst_QHash::count() #ifndef Q_CC_SUN QVERIFY( MyClass::count == 1 ); #endif - QVERIFY( map.count() == 1 ); + QVERIFY( map.size() == 1 ); (void)map["Torben"].str; (void)map["Lars"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); + QVERIFY( map.size() == 2 ); const Map& cmap = map; (void)cmap["Depp"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); - QVERIFY( cmap.count() == 2 ); + QVERIFY( map.size() == 2 ); + QVERIFY( cmap.size() == 2 ); } QCOMPARE( MyClass::count, 0 ); { @@ -1688,26 +1688,26 @@ void tst_QHash::qmultihash_specific() } QVERIFY(hash1.contains(9, 99)); - QCOMPARE(hash1.count(), 45); + QCOMPARE(hash1.size(), 45); hash1.remove(9, 99); QVERIFY(!hash1.contains(9, 99)); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); hash1.remove(9, 99); QVERIFY(!hash1.contains(9, 99)); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); hash1.remove(1, 99); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); hash1.insert(1, 99); hash1.insert(1, 99); - QCOMPARE(hash1.count(), 46); + QCOMPARE(hash1.size(), 46); hash1.remove(1, 99); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); hash1.remove(1, 99); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); { QMultiHash<int, int>::const_iterator i = hash1.constFind(1, 11); @@ -1753,10 +1753,10 @@ void tst_QHash::qmultihash_specific() } QCOMPARE(hash1.count(9), 8); - QCOMPARE(hash1.count(), 44); + QCOMPARE(hash1.size(), 44); hash1.remove(9); QCOMPARE(hash1.count(9), 0); - QCOMPARE(hash1.count(), 36); + QCOMPARE(hash1.size(), 36); { QMultiHash<int, int> map1; @@ -1772,7 +1772,7 @@ void tst_QHash::qmultihash_specific() map2.insert(42, 1); map2.insert(10, 2); map2.insert(48, 3); - QCOMPARE(map1.count(), map2.count()); + QCOMPARE(map1.size(), map2.size()); QVERIFY(map1.remove(42,5)); QVERIFY(map1 != map2); QVERIFY(map2.remove(42,5)); @@ -1781,7 +1781,7 @@ void tst_QHash::qmultihash_specific() QHash<int, int> hash; hash.insert(-1, -1); map2.unite(hash); - QCOMPARE(map2.count(), 6); + QCOMPARE(map2.size(), 6); QCOMPARE(map2[-1], -1); } } @@ -2168,7 +2168,7 @@ void tst_QHash::twoArguments_qHash() void tst_QHash::initializerList() { QHash<int, QString> hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; - QCOMPARE(hash.count(), 2); + QCOMPARE(hash.size(), 2); QCOMPARE(hash[1], QString("hello")); QCOMPARE(hash[2], QString("initializer_list")); @@ -2178,9 +2178,9 @@ void tst_QHash::initializerList() // QCOMPARE(stdh[1], QString("bar")); QMultiHash<QString, int> multiHash{{"il", 1}, {"il", 2}, {"il", 3}}; - QCOMPARE(multiHash.count(), 3); + QCOMPARE(multiHash.size(), 3); QList<int> values = multiHash.values("il"); - QCOMPARE(values.count(), 3); + QCOMPARE(values.size(), 3); QHash<int, int> emptyHash{}; QVERIFY(emptyHash.isEmpty()); @@ -2352,7 +2352,7 @@ void tst_QHash::insert_hash() hash.insert(hash2); - QCOMPARE(hash.count(), 5); + QCOMPARE(hash.size(), 5); for (int i = 0; i < 5; ++i) QCOMPARE(hash[i], i); } @@ -2364,7 +2364,7 @@ void tst_QHash::insert_hash() hash.insert(hash2); - QCOMPARE(hash.count(), 1); + QCOMPARE(hash.size(), 1); QCOMPARE(hash[0], 5); } { @@ -2374,7 +2374,7 @@ void tst_QHash::insert_hash() hash.insert(hash2); - QCOMPARE(hash.count(), 1); + QCOMPARE(hash.size(), 1); QCOMPARE(hash[0], 5); QCOMPARE(hash, hash2); } @@ -2387,7 +2387,7 @@ void tst_QHash::insert_hash() // insert into ourself, nothing should happen hash.insert(hash); - QCOMPARE(hash.count(), 3); + QCOMPARE(hash.size(), 3); QCOMPARE(hash[0], 7); QCOMPARE(hash[2], 5); QCOMPARE(hash[7], 55); @@ -2561,13 +2561,13 @@ void tst_QHash::countInEmptyHash() { { QHash<int, int> hash; - QCOMPARE(hash.count(), 0); + QCOMPARE(hash.size(), 0); QCOMPARE(hash.count(42), 0); } { QMultiHash<int, int> hash; - QCOMPARE(hash.count(), 0); + QCOMPARE(hash.size(), 0); QCOMPARE(hash.count(42), 0); QCOMPARE(hash.count(42, 1), 0); } diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index e797b76f69..482079b0fe 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1078,20 +1078,20 @@ void tst_QList::count() const { // zero size QList<T> myvec; - QVERIFY(myvec.count() == 0); + QVERIFY(myvec.size() == 0); QVERIFY(!myvec.isDetached()); // grow myvec.append(SimpleValue<T>::at(0)); - QVERIFY(myvec.count() == 1); + QVERIFY(myvec.size() == 1); myvec.append(SimpleValue<T>::at(1)); - QVERIFY(myvec.count() == 2); + QVERIFY(myvec.size() == 2); // shrink myvec.remove(0); - QVERIFY(myvec.count() == 1); + QVERIFY(myvec.size() == 1); myvec.remove(0); - QVERIFY(myvec.count() == 0); + QVERIFY(myvec.size() == 0); } // count of items @@ -1905,11 +1905,11 @@ void tst_QList::move() const list << T_FOO << T_BAR << T_BAZ; // move an item - list.move(0, list.count() - 1); + list.move(0, list.size() - 1); QCOMPARE(list, QList<T>() << T_BAR << T_BAZ << T_FOO); // move it back - list.move(list.count() - 1, 0); + list.move(list.size() - 1, 0); QCOMPARE(list, QList<T>() << T_FOO << T_BAR << T_BAZ); // move an item in the middle @@ -2673,24 +2673,24 @@ void tst_QList::size() const // zero size QList<T> myvec; QVERIFY(myvec.size() == 0); - QCOMPARE(myvec.length(), myvec.size()); + QCOMPARE(myvec.size(), myvec.size()); QVERIFY(!myvec.isDetached()); // grow myvec.append(SimpleValue<T>::at(0)); QVERIFY(myvec.size() == 1); - QCOMPARE(myvec.length(), myvec.size()); + QCOMPARE(myvec.size(), myvec.size()); myvec.append(SimpleValue<T>::at(1)); QVERIFY(myvec.size() == 2); - QCOMPARE(myvec.length(), myvec.size()); + QCOMPARE(myvec.size(), myvec.size()); // shrink myvec.remove(0); QVERIFY(myvec.size() == 1); - QCOMPARE(myvec.length(), myvec.size()); + QCOMPARE(myvec.size(), myvec.size()); myvec.remove(0); QVERIFY(myvec.size() == 0); - QCOMPARE(myvec.length(), myvec.size()); + QCOMPARE(myvec.size(), myvec.size()); } // ::squeeze() is tested in ::capacity(). diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp index 08b7afae04..12fc2f8e43 100644 --- a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp +++ b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp @@ -122,7 +122,7 @@ void tst_QMessageAuthenticationCode::result_incremental() QFETCH(QByteArray, message); QFETCH(QByteArray, code); - int index = message.length() / 2; + int index = message.size() / 2; QByteArray leftPart(message.mid(0, index)); QByteArray rightPart(message.mid(index)); diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index e72bf34581..97c5ea1f57 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -8,7 +8,7 @@ int toNumber(const QString &str) { int res = 0; - for (int i = 0; i < str.length(); ++i) + for (int i = 0; i < str.size(); ++i) res = (res * 10) + str[i].digitValue(); return res; } @@ -139,44 +139,44 @@ void tst_QSet::size() QSet<int> set; QVERIFY(set.size() == 0); QVERIFY(set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); QVERIFY(!set.isDetached()); set.insert(1); QVERIFY(set.size() == 1); QVERIFY(!set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); set.insert(1); QVERIFY(set.size() == 1); QVERIFY(!set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); set.insert(2); QVERIFY(set.size() == 2); QVERIFY(!set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); set.remove(1); QVERIFY(set.size() == 1); QVERIFY(!set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); set.remove(1); QVERIFY(set.size() == 1); QVERIFY(!set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); set.remove(2); QVERIFY(set.size() == 0); QVERIFY(set.isEmpty()); - QVERIFY(set.count() == set.size()); + QVERIFY(set.size() == set.size()); QVERIFY(set.isEmpty() == set.empty()); } @@ -1011,7 +1011,7 @@ void tst_QSet::makeSureTheComfortFunctionsCompile() void tst_QSet::initializerList() { QSet<int> set = {1, 1, 2, 3, 4, 5}; - QCOMPARE(set.count(), 5); + QCOMPARE(set.size(), 5); QVERIFY(set.contains(1)); QVERIFY(set.contains(2)); QVERIFY(set.contains(3)); @@ -1020,7 +1020,7 @@ void tst_QSet::initializerList() // check _which_ of the equal elements gets inserted (in the QHash/QMap case, it's the last): const QSet<IdentityTracker> set2 = {{1, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; - QCOMPARE(set2.count(), 5); + QCOMPARE(set2.size(), 5); const int dummy = -1; const IdentityTracker searchKey = {1, dummy}; QCOMPARE(set2.find(searchKey)->id, 0); diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 90609eb998..f455d7647e 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -2058,11 +2058,11 @@ void tst_QSharedPointer::threadStressTest() base.clear(); // start threads - for (int i = 0; i < allThreads.count(); ++i) + for (int i = 0; i < allThreads.size(); ++i) if (allThreads[i]) allThreads[i]->start(); // wait for them to finish - for (int i = 0; i < allThreads.count(); ++i) + for (int i = 0; i < allThreads.size(); ++i) if (allThreads[i]) allThreads[i]->wait(); qDeleteAll(allThreads); diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index d1a1d2c169..7d0e121b30 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -80,7 +80,7 @@ void tst_QTimeLine::range() timeLine.setStartFrame(5000); QVERIFY(timeLine.currentFrame() > oldValue); timeLine.setFrameRange(0, 500); - QTRY_VERIFY(spy.count() > 1); + QTRY_VERIFY(spy.size() > 1); QVERIFY(timeLine.currentFrame() < oldValue); } @@ -102,7 +102,7 @@ void tst_QTimeLine::currentTime() spy.clear(); timeLine.setCurrentTime(timeLine.duration()/2); timeLine.setCurrentTime(timeLine.duration()/2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QCOMPARE(timeLine.currentTime(), timeLine.duration()/2); timeLine.resume(); @@ -153,10 +153,10 @@ void tst_QTimeLine::bindableCurrentTime() spy.clear(); QProperty<int> referenceCurrentTime(timeLine.duration() / 2); timeLine.bindableCurrentTime().setBinding([&]() { return referenceCurrentTime.value(); }); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // setting it a second time to check that valueChanged() is emitted only once referenceCurrentTime = timeLine.duration() / 2; - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QCOMPARE(timeLine.currentTime(), timeLine.duration() / 2); @@ -172,7 +172,7 @@ void tst_QTimeLine::bindableCurrentTime() spy.clear(); referenceCurrentTime = 0; QCOMPARE(currentTimeObserver.value(), timeLine.duration()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTimeLine::duration() @@ -236,7 +236,7 @@ void tst_QTimeLine::frameRate() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - int slowCount = spy.count(); + int slowCount = spy.size(); // Faster!! timeLine.setUpdateInterval(1000 / 100); @@ -245,7 +245,7 @@ void tst_QTimeLine::frameRate() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count())); + QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size())); } void tst_QTimeLine::bindableUpdateInterval() @@ -270,7 +270,7 @@ void tst_QTimeLine::bindableUpdateInterval() timeLine.start(); QTest::qWait(timeLine.duration() * 2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - int slowCount = spy.count(); + int slowCount = spy.size(); // Faster!! updateIntervalReference = 1000 / 100; @@ -279,7 +279,7 @@ void tst_QTimeLine::bindableUpdateInterval() timeLine.start(); QTest::qWait(timeLine.duration() * 2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count())); + QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size())); } void tst_QTimeLine::value() @@ -294,7 +294,7 @@ void tst_QTimeLine::value() QTRY_VERIFY(timeLine.currentValue() > 0); QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); QCOMPARE(timeLine.currentValue(), 1.0); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); // Reverse should decrease the value timeLine.setCurrentTime(100); @@ -380,8 +380,8 @@ void tst_QTimeLine::loopCount() loop.exec(); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(frameChangedSpy.count(), 11); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(frameChangedSpy.size(), 11); for (int i = 0; i < 11; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i+1) % 3); } @@ -390,8 +390,8 @@ void tst_QTimeLine::loopCount() timeLine.start(); loop.exec(); - QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(frameChangedSpy.count(), 22); + QCOMPARE(finishedSpy.size(), 2); + QCOMPARE(frameChangedSpy.size(), 22); for (int i = 11; i < 22; ++i) { QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i+2) % 3); } @@ -456,8 +456,8 @@ void tst_QTimeLine::bindableLoopCount() loop.exec(); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(frameChangedSpy.count(), 11); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(frameChangedSpy.size(), 11); for (int i = 0; i < 11; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i + 1) % 3); } @@ -466,8 +466,8 @@ void tst_QTimeLine::bindableLoopCount() timeLine.start(); loop.exec(); - QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(frameChangedSpy.count(), 22); + QCOMPARE(finishedSpy.size(), 2); + QCOMPARE(frameChangedSpy.size(), 22); for (int i = 11; i < 22; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i + 2) % 3); } @@ -636,14 +636,14 @@ void tst_QTimeLine::frameChanged() timeLine.start(); QTest::qWait(timeLine.duration()/2); QCOMPARE(timeLine.state(), QTimeLine::Running); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QTest::qWait(timeLine.duration()); if (timeLine.state() != QTimeLine::NotRunning) QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - if (spy.count() != 1) + if (spy.size() != 1) QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // Test what happens when the frames are all emitted well before duration expires. timeLine.setUpdateInterval(5); @@ -652,7 +652,7 @@ void tst_QTimeLine::frameChanged() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QCOMPARE(spy.count(), 10); + QCOMPARE(spy.size(), 10); } void tst_QTimeLine::stopped() @@ -665,11 +665,11 @@ void tst_QTimeLine::stopped() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); spy.clear(); timeLine.start(); timeLine.stop(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); timeLine.setDirection(QTimeLine::Backward); QCOMPARE(timeLine.loopCount(), 1); } @@ -681,13 +681,13 @@ void tst_QTimeLine::finished() QSignalSpy spy(&timeLine, &QTimeLine::finished); QVERIFY(spy.isValid()); timeLine.start(); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); spy.clear(); timeLine.start(); timeLine.stop(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTimeLine::isRunning() @@ -720,7 +720,7 @@ void tst_QTimeLine::multipleTimeLines() timeLine.start(); timeLineKiller.stop(); QTest::qWait(timeLine.duration()*2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QTimeLine::sineCurve() diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 508f709533..c21dfbfafb 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -936,8 +936,8 @@ void tst_QVarLengthArray::count() // tests size(), count() and length(), since they're the same thing { const QVarLengthArray<int> list; - QCOMPARE(list.length(), 0); - QCOMPARE(list.count(), 0); + QCOMPARE(list.size(), 0); + QCOMPARE(list.size(), 0); QCOMPARE(list.size(), 0); QVERIFY(list.isEmpty()); } @@ -945,8 +945,8 @@ void tst_QVarLengthArray::count() { QVarLengthArray<int> list; list.append(0); - QCOMPARE(list.length(), 1); - QCOMPARE(list.count(), 1); + QCOMPARE(list.size(), 1); + QCOMPARE(list.size(), 1); QCOMPARE(list.size(), 1); QVERIFY(!list.isEmpty()); } @@ -955,8 +955,8 @@ void tst_QVarLengthArray::count() QVarLengthArray<int> list; list.append(0); list.append(1); - QCOMPARE(list.length(), 2); - QCOMPARE(list.count(), 2); + QCOMPARE(list.size(), 2); + QCOMPARE(list.size(), 2); QCOMPARE(list.size(), 2); QVERIFY(!list.isEmpty()); } @@ -966,8 +966,8 @@ void tst_QVarLengthArray::count() list.append(0); list.append(0); list.append(0); - QCOMPARE(list.length(), 3); - QCOMPARE(list.count(), 3); + QCOMPARE(list.size(), 3); + QCOMPARE(list.size(), 3); QCOMPARE(list.size(), 3); QVERIFY(!list.isEmpty()); } @@ -978,23 +978,23 @@ void tst_QVarLengthArray::count() list.append(0); list.append(0); list.append(0); - QCOMPARE(list.length(), 3); - QCOMPARE(list.count(), 3); + QCOMPARE(list.size(), 3); + QCOMPARE(list.size(), 3); QCOMPARE(list.size(), 3); QVERIFY(!list.isEmpty()); list.removeLast(); - QCOMPARE(list.length(), 2); - QCOMPARE(list.count(), 2); + QCOMPARE(list.size(), 2); + QCOMPARE(list.size(), 2); QCOMPARE(list.size(), 2); QVERIFY(!list.isEmpty()); list.removeLast(); - QCOMPARE(list.length(), 1); - QCOMPARE(list.count(), 1); + QCOMPARE(list.size(), 1); + QCOMPARE(list.size(), 1); QCOMPARE(list.size(), 1); QVERIFY(!list.isEmpty()); list.removeLast(); - QCOMPARE(list.length(), 0); - QCOMPARE(list.count(), 0); + QCOMPARE(list.size(), 0); + QCOMPARE(list.size(), 0); QCOMPARE(list.size(), 0); QVERIFY(list.isEmpty()); } @@ -1033,16 +1033,16 @@ void tst_QVarLengthArray::first() QCOMPARE(list.first(), 27); list.append(1987); QCOMPARE(list.first(), 27); - QCOMPARE(list.length(), 3); + QCOMPARE(list.size(), 3); // remove some, make sure it stays sane list.removeLast(); QCOMPARE(list.first(), 27); - QCOMPARE(list.length(), 2); + QCOMPARE(list.size(), 2); list.removeLast(); QCOMPARE(list.first(), 27); - QCOMPARE(list.length(), 1); + QCOMPARE(list.size(), 1); } void tst_QVarLengthArray::last() @@ -1055,16 +1055,16 @@ void tst_QVarLengthArray::last() QCOMPARE(list.last(), 4); list.append(1987); QCOMPARE(list.last(), 1987); - QCOMPARE(list.length(), 3); + QCOMPARE(list.size(), 3); // remove some, make sure it stays sane list.removeLast(); QCOMPARE(list.last(), 4); - QCOMPARE(list.length(), 2); + QCOMPARE(list.size(), 2); list.removeLast(); QCOMPARE(list.last(), 27); - QCOMPARE(list.length(), 1); + QCOMPARE(list.size(), 1); } void tst_QVarLengthArray::squeeze() diff --git a/tests/auto/dbus/qdbusabstractadaptor/myobject.h b/tests/auto/dbus/qdbusabstractadaptor/myobject.h index 3bb211c1ad..d2c4b14805 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/myobject.h +++ b/tests/auto/dbus/qdbusabstractadaptor/myobject.h @@ -26,7 +26,7 @@ public slots: signature = msg.signature(); path = msg.path(); value.clear(); - if (msg.arguments().count()) + if (msg.arguments().size()) value = msg.arguments().at(0); } diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 7242e6c353..4a5e6c9d7e 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1840,7 +1840,7 @@ void tst_QDBusAbstractAdaptor::typeMatching() reply = iface.call(QDBus::BlockWithGui, "retrieve" + basename); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); const QVariant &retval = reply.arguments().at(0); QVERIFY(compare(retval, value)); @@ -1858,7 +1858,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValue() QDBusInterface remote(con.baseService(), "/", "local.Interface3", con); QDBusMessage reply = remote.call(QDBus::BlockWithGui, "methodStringString", testString); - QCOMPARE(reply.arguments().count(), 2); + QCOMPARE(reply.arguments().size(), 2); QDBusReply<int> intreply = reply; QVERIFY(intreply.isValid()); @@ -1881,7 +1881,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValuePeer() QDBusInterface remote(QString(), "/", "local.Interface3", con); QDBusMessage reply = remote.call(QDBus::BlockWithGui, "methodStringString", testString); - QCOMPARE(reply.arguments().count(), 2); + QCOMPARE(reply.arguments().size(), 2); QDBusReply<int> intreply = reply; QVERIFY(intreply.isValid()); diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index c42ec5de9d..09ce947ccc 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -114,7 +114,7 @@ void tst_QDBusConnection::sendSignalToName() QVERIFY(con.send(msg)); - QTRY_COMPARE(spy.args.count(), 1); + QTRY_COMPARE(spy.args.size(), 1); QCOMPARE(spy.args.at(0).toString(), QString("ping")); } @@ -139,7 +139,7 @@ void tst_QDBusConnection::sendSignalToOtherName() QTest::qWait(1000); - QCOMPARE(spy.args.count(), 0); + QCOMPARE(spy.args.size(), 0); } void tst_QDBusConnection::send() @@ -153,7 +153,7 @@ void tst_QDBusConnection::send() QDBusMessage reply = con.call(msg); - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); QCOMPARE(reply.arguments().at(0).typeName(), "QStringList"); QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); } @@ -172,7 +172,7 @@ void tst_QDBusConnection::sendWithGui() QDBusMessage reply = con.call(msg, QDBus::BlockWithGui); - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); QCOMPARE(reply.arguments().at(0).typeName(), "QStringList"); QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); } @@ -191,7 +191,7 @@ void tst_QDBusConnection::sendAsync() "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames"); QVERIFY(con.callWithCallback(msg, &spy, SLOT(asyncReply(QDBusMessage)))); - QTRY_COMPARE(spy.args.count(), 1); + QTRY_COMPARE(spy.args.size(), 1); QCOMPARE(spy.args.value(0).typeName(), "QStringList"); QVERIFY(spy.args.at(0).toStringList().contains(con.baseService())); } @@ -214,7 +214,7 @@ void tst_QDBusConnection::connect() QVERIFY(con.send(msg)); - QTRY_COMPARE(spy.args.count(), 1); + QTRY_COMPARE(spy.args.size(), 1); QCOMPARE(spy.args.at(0).toString(), QString("ping")); } @@ -1026,7 +1026,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject() "local.BaseObject", "anotherMethod"); QDBusMessage reply = con.call(msg, QDBus::Block); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); - QCOMPARE(reply.arguments().count(), 0); + QCOMPARE(reply.arguments().size(), 0); QVERIFY_HOOKCALLED(); } diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 10edc0e322..ecaf9b33cb 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -468,14 +468,14 @@ void tst_QDBusInterface::callMethod() QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); QVariant v = MyObject::callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); QCOMPARE(dv.variant().toString(), QString("foo")); // verify reply - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); v = reply.arguments().at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -487,14 +487,14 @@ void tst_QDBusInterface::callMethod() QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); v = MyObject::callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); QCOMPARE(dv.variant().toString(), QString("bar")); // verify reply - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); v = reply.arguments().at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -515,7 +515,7 @@ void tst_QDBusInterface::invokeMethod() QCOMPARE(MyObject::callCount, 1); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); QVariant v = MyObject::callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -527,7 +527,7 @@ void tst_QDBusInterface::invokeMethod() QCOMPARE(MyObject::callCount, 2); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); v = MyObject::callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -549,7 +549,7 @@ void tst_QDBusInterface::invokeMethodWithReturn() QCOMPARE(MyObject::callCount, 1); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); QVariant v = MyObject::callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -564,7 +564,7 @@ void tst_QDBusInterface::invokeMethodWithReturn() QCOMPARE(MyObject::callCount, 2); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); v = MyObject::callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -593,7 +593,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() QCOMPARE(MyObject::callCount, 1); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 2); + QCOMPARE(MyObject::callArgs.size(), 2); QVariant v = MyObject::callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -618,7 +618,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() QCOMPARE(MyObject::callCount, 2); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 2); + QCOMPARE(MyObject::callArgs.size(), 2); v = MyObject::callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -649,7 +649,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() QCOMPARE(MyObject::callCount, 1); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); QVariant v = MyObject::callArgs.at(0); QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); QCOMPARE(qdbus_cast<QList<int> >(v), arg); @@ -663,7 +663,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() QCOMPARE(MyObject::callCount, 2); // verify what the callee received - QCOMPARE(MyObject::callArgs.count(), 1); + QCOMPARE(MyObject::callArgs.size(), 1); v = MyObject::callArgs.at(0); QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); QCOMPARE(qdbus_cast<QList<int> >(v), arg2); @@ -703,14 +703,14 @@ void tst_QDBusInterface::callMethodPeer() // verify what the callee received QVariantList callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); QVariant v = callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); QCOMPARE(dv.variant().toString(), QString("foo")); // verify reply - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); v = reply.arguments().at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -723,14 +723,14 @@ void tst_QDBusInterface::callMethodPeer() // verify what the callee received callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); v = callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); QCOMPARE(dv.variant().toString(), QString("bar")); // verify reply - QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().size(), 1); v = reply.arguments().at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -752,7 +752,7 @@ void tst_QDBusInterface::invokeMethodPeer() // verify what the callee received QVariantList callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); QVariant v = callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -765,7 +765,7 @@ void tst_QDBusInterface::invokeMethodPeer() // verify what the callee received callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); v = callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -788,7 +788,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer() // verify what the callee received QVariantList callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); QVariant v = callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -804,7 +804,7 @@ void tst_QDBusInterface::invokeMethodWithReturnPeer() // verify what the callee received callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); v = callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -834,7 +834,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer() // verify what the callee received QVariantList callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 2); + QCOMPARE(callArgs.size(), 2); QVariant v = callArgs.at(0); QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -860,7 +860,7 @@ void tst_QDBusInterface::invokeMethodWithMultiReturnPeer() // verify what the callee received callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 2); + QCOMPARE(callArgs.size(), 2); v = callArgs.at(0); dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().userType(), QMetaType::QString); @@ -892,7 +892,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturnPeer() // verify what the callee received QVariantList callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); QVariant v = callArgs.at(0); QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); QCOMPARE(qdbus_cast<QList<int> >(v), arg); @@ -907,7 +907,7 @@ void tst_QDBusInterface::invokeMethodWithComplexReturnPeer() // verify what the callee received callArgs = callArgsPeer(); - QCOMPARE(callArgs.count(), 1); + QCOMPARE(callArgs.size(), 1); v = callArgs.at(0); QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); QCOMPARE(qdbus_cast<QList<int> >(v), arg2); diff --git a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp index f5f72de07a..7ea5958805 100644 --- a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp +++ b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp @@ -137,7 +137,7 @@ void tst_QDBusLocalCalls::makeCalls() QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); QVariantList replyArgs = replyMsg.arguments(); - QCOMPARE(replyArgs.count(), 1); + QCOMPARE(replyArgs.size(), 1); QCOMPARE(replyArgs.at(0), value); } @@ -152,7 +152,7 @@ void tst_QDBusLocalCalls::makeCallsVariant() QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); QVariantList replyArgs = replyMsg.arguments(); - QCOMPARE(replyArgs.count(), 1); + QCOMPARE(replyArgs.size(), 1); const QVariant &reply = replyArgs.at(0); QCOMPARE(reply.userType(), qMetaTypeId<QDBusVariant>()); @@ -169,7 +169,7 @@ void tst_QDBusLocalCalls::makeCallsTwoRets() QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); QVariantList replyArgs = replyMsg.arguments(); - QCOMPARE(replyArgs.count(), 2); + QCOMPARE(replyArgs.size(), 2); QCOMPARE(replyArgs.at(0).toString(), QString::fromLatin1("One")); QCOMPARE(replyArgs.at(1).toString(), QString::fromLatin1("Two")); } @@ -189,7 +189,7 @@ void tst_QDBusLocalCalls::makeCallsComplex() QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); QVariantList replyArgs = replyMsg.arguments(); - QCOMPARE(replyArgs.count(), 1); + QCOMPARE(replyArgs.size(), 1); const QVariant &reply = replyArgs.at(0); QCOMPARE(reply.userType(), qMetaTypeId<QDBusArgument>()); QCOMPARE(qdbus_cast<QList<int> >(reply), value); diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 71dca905c7..e0e82af706 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -334,7 +334,7 @@ bool compare(const QDBusVariant &s1, const QDBusVariant &s2) template<typename T> bool compare(const QList<T> &l1, const QList<T> &l2) { - if (l1.count() != l2.count()) + if (l1.size() != l2.size()) return false; typename QList<T>::ConstIterator it1 = l1.constBegin(); @@ -349,7 +349,7 @@ bool compare(const QList<T> &l1, const QList<T> &l2) template<typename Key, typename T> bool compare(const QMap<Key, T> &m1, const QMap<Key, T> &m2) { - if (m1.count() != m2.size()) + if (m1.size() != m2.size()) return false; typename QMap<Key, T>::ConstIterator i1 = m1.constBegin(); typename QMap<Key, T>::ConstIterator end = m1.constEnd(); diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index d3d4292563..fe9ff866f3 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -757,9 +757,9 @@ void tst_QDBusMarshall::sendBasic() qPrintable(reply.errorName() + ": " + reply.errorMessage())); //qDebug() << reply; - QCOMPARE(reply.arguments().count(), msg.arguments().count()); + QCOMPARE(reply.arguments().size(), msg.arguments().size()); QTEST(reply.signature(), "sig"); - for (int i = 0; i < reply.arguments().count(); ++i) { + for (int i = 0; i < reply.arguments().size(); ++i) { QVERIFY(compare(reply.arguments().at(i), msg.arguments().at(i))); //printf("\n! %s\n* %s\n", qPrintable(qDBusArgumentToString(reply.arguments().at(i))), qPrintable(stringResult)); QCOMPARE(QDBusUtil::argumentToString(reply.arguments().at(i)), stringResult); @@ -781,9 +781,9 @@ void tst_QDBusMarshall::sendVariant() QDBusMessage reply = con.call(msg); // qDebug() << reply; - QCOMPARE(reply.arguments().count(), msg.arguments().count()); + QCOMPARE(reply.arguments().size(), msg.arguments().size()); QCOMPARE(reply.signature(), QString("v")); - for (int i = 0; i < reply.arguments().count(); ++i) + for (int i = 0; i < reply.arguments().size(); ++i) QVERIFY(compare(reply.arguments().at(i), msg.arguments().at(i))); } @@ -1205,7 +1205,7 @@ void tst_QDBusMarshall::receiveUnknownType() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spy.list.size(), 1); - QCOMPARE(spy.list.at(0).arguments().count(), 1); + QCOMPARE(spy.list.at(0).arguments().size(), 1); QFETCH(int, receivedTypeId); //qDebug() << spy.list.at(0).arguments().at(0).typeName(); QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId); diff --git a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp index f8f272ab08..4bcee5cada 100644 --- a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp +++ b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp @@ -157,7 +157,7 @@ void tst_QDBusPendingCall::waitForFinished() QCOMPARE(reply.signature(), QString("as")); const QVariantList args = ac.reply().arguments(); - QCOMPARE(args.count(), 1); + QCOMPARE(args.size(), 1); const QVariant &arg = args.at(0); QCOMPARE(arg.userType(), QMetaType::QStringList); diff --git a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp index 6c80334a5c..7ac2c6690e 100644 --- a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp +++ b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp @@ -99,12 +99,12 @@ void tst_QDBusServiceWatcher::watchForCreation() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), registeredName); - QCOMPARE(spyU.count(), 0); + QCOMPARE(spyU.size(), 0); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -122,12 +122,12 @@ void tst_QDBusServiceWatcher::watchForCreation() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), registeredName); - QCOMPARE(spyU.count(), 0); + QCOMPARE(spyU.size(), 0); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -163,12 +163,12 @@ void tst_QDBusServiceWatcher::watchForDisappearance() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 0); + QCOMPARE(spyR.size(), 0); - QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.size(), 1); QCOMPARE(spyU.at(0).at(0).toString(), registeredName); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); @@ -197,12 +197,12 @@ void tst_QDBusServiceWatcher::watchForDisappearanceUniqueConnection() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 0); + QCOMPARE(spyR.size(), 0); - QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.size(), 1); QCOMPARE(spyU.at(0).at(0).toString(), watchedName); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), watchedName); QCOMPARE(spyO.at(0).at(1).toString(), watchedName); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); @@ -234,12 +234,12 @@ void tst_QDBusServiceWatcher::watchForOwnerChange() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), registeredName); - QCOMPARE(spyU.count(), 0); + QCOMPARE(spyU.size(), 0); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -257,13 +257,13 @@ void tst_QDBusServiceWatcher::watchForOwnerChange() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), registeredName); - QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.size(), 1); QCOMPARE(spyU.at(0).at(0).toString(), registeredName); - QCOMPARE(spyO.count(), 2); + QCOMPARE(spyO.size(), 2); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); @@ -298,12 +298,12 @@ void tst_QDBusServiceWatcher::modeChange() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), registeredName); - QCOMPARE(spyU.count(), 0); + QCOMPARE(spyU.size(), 0); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -321,12 +321,12 @@ void tst_QDBusServiceWatcher::modeChange() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 0); + QCOMPARE(spyR.size(), 0); - QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.size(), 1); QCOMPARE(spyU.at(0).at(0).toString(), registeredName); - QCOMPARE(spyO.count(), 1); + QCOMPARE(spyO.size(), 1); QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); @@ -377,9 +377,9 @@ void tst_QDBusServiceWatcher::setConnection() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 1); + QCOMPARE(spyR.size(), 1); QCOMPARE(spyR.at(0).at(0).toString(), serviceName); - QCOMPARE(spyU.count(), 0); + QCOMPARE(spyU.size(), 0); // is the system bus available? if (!QDBusConnection::systemBus().isConnected()) @@ -400,9 +400,9 @@ void tst_QDBusServiceWatcher::setConnection() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spyR.count(), 0); + QCOMPARE(spyR.size(), 0); - QCOMPARE(spyU.count(), 1); + QCOMPARE(spyU.size(), 1); QCOMPARE(spyU.at(0).at(0).toString(), watchedName); } diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp index 2c53c4a403..536520ea0d 100644 --- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp @@ -173,7 +173,7 @@ void tst_QDBusType::isValidFixedType() QFETCH(QString, data); QFETCH(bool, result); QFETCH(bool, isValid); - QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types"); + QVERIFY2(data.size() == 1, "Test is malformed, this function must test only one-letter types"); QVERIFY(isValid || (!isValid && !result)); int type = data.at(0).unicode(); @@ -195,7 +195,7 @@ void tst_QDBusType::isValidBasicType() QFETCH(QString, data); QFETCH(bool, result); QFETCH(bool, isValid); - QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types"); + QVERIFY2(data.size() == 1, "Test is malformed, this function must test only one-letter types"); QVERIFY(isValid || (!isValid && !result)); int type = data.at(0).unicode(); diff --git a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp index 3e01d18ffd..512eb35f45 100644 --- a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp +++ b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp @@ -106,9 +106,9 @@ void tst_QDBusXmlParser::parsing_common(const QString &xmlData) QFETCH(int, objectCount); QFETCH(int, annotationCount); QFETCH(QStringList, introspection); - QCOMPARE(obj.interfaces.count(), interfaceCount); - QCOMPARE(obj.childObjects.count(), objectCount); - QCOMPARE(QDBusIntrospection::parseInterface(xmlData).annotations.count(), annotationCount); + QCOMPARE(obj.interfaces.size(), interfaceCount); + QCOMPARE(obj.childObjects.size(), objectCount); + QCOMPARE(QDBusIntrospection::parseInterface(xmlData).annotations.size(), annotationCount); QDBusIntrospection::Interfaces ifaces = QDBusIntrospection::parseInterfaces(xmlData); @@ -327,7 +327,7 @@ void tst_QDBusXmlParser::methods() QFETCH(MethodMap, methodMap); MethodMap parsedMap = iface.methods; - QCOMPARE(parsedMap.count(), methodMap.count()); + QCOMPARE(parsedMap.size(), methodMap.size()); QCOMPARE(parsedMap, methodMap); } @@ -441,7 +441,7 @@ void tst_QDBusXmlParser::signals_() QFETCH(SignalMap, signalMap); SignalMap parsedMap = iface.signals_; - QCOMPARE(signalMap.count(), parsedMap.count()); + QCOMPARE(signalMap.size(), parsedMap.size()); QCOMPARE(signalMap, parsedMap); } @@ -531,7 +531,7 @@ void tst_QDBusXmlParser::properties() QFETCH(PropertyMap, propertyMap); PropertyMap parsedMap = iface.properties; - QCOMPARE(propertyMap.count(), parsedMap.count()); + QCOMPARE(propertyMap.size(), parsedMap.size()); QCOMPARE(propertyMap, parsedMap); } diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp index b2f9c038aa..1cf13f6f9c 100644 --- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp +++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp @@ -156,7 +156,7 @@ void tst_QMovie::playMovie() movie.start(); QCOMPARE(movie.state(), QMovie::Running); QTestEventLoop::instance().enterLoop(2); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); QCOMPARE(movie.state(), QMovie::Running); QCOMPARE(movie.currentFrameNumber(), 0); } diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp index ec724c284f..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()); @@ -862,7 +862,7 @@ void tst_QFileSystemModel::sort() expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + "."; if (fileDialogMode) { - QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count()); + QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.size()); // File dialog Mode means sub trees are not sorted, only the current root. // There's no way we can check that the sub tree is "not sorted"; just check if it // has the same contents of the expected list @@ -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 40834459e5..6f42c45821 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -757,10 +757,10 @@ void tst_QStandardItem::takeColumn() QList<QStandardItem *> taken = item.takeColumn(column); if (expectSuccess) { - QCOMPARE(taken.count(), item.rowCount()); + QCOMPARE(taken.size(), item.rowCount()); QCOMPARE(item.columnCount(), columns - 1); int index = column; - for (int i = 0; i < taken.count(); ++i) { + for (int i = 0; i < taken.size(); ++i) { QCOMPARE(taken.at(i), originalChildren.takeAt(index)); index += item.columnCount(); } @@ -818,10 +818,10 @@ void tst_QStandardItem::takeRow() QList<QStandardItem *> taken = item.takeRow(row); if (expectSuccess) { - QCOMPARE(taken.count(), item.columnCount()); + QCOMPARE(taken.size(), item.columnCount()); QCOMPARE(item.rowCount(), rows - 1); int index = row * columns; - for (int i = 0; i < taken.count(); ++i) { + for (int i = 0; i < taken.size(); ++i) { QCOMPARE(taken.at(i), originalChildren.takeAt(index)); } index = 0; @@ -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; @@ -1001,7 +1001,7 @@ public: int type() const override { return QStandardItem::UserType + 1; } bool operator<(const QStandardItem &other) const override { - return text().length() < other.text().length(); + return text().size() < other.text().size(); } using QStandardItem::clone; @@ -1027,8 +1027,8 @@ void tst_QStandardItem::subclassing() QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged); item->emitDataChanged(); - QCOMPARE(itemChangedSpy.count(), 1); - QCOMPARE(itemChangedSpy.at(0).count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); + QCOMPARE(itemChangedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)), item); CustomItem *child0 = new CustomItem("cc"); diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index ea9077e2a0..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)); @@ -906,15 +906,15 @@ void tst_QStandardItemModel::findItems() model.item(1)->appendRow(new QStandardItem(QLatin1String("foo"))); QList<QStandardItem*> matches; matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 0); - QCOMPARE(matches.count(), 2); + QCOMPARE(matches.size(), 2); matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly, 0); - QCOMPARE(matches.count(), 1); + QCOMPARE(matches.size(), 1); matches = model.findItems(QLatin1String("food"), Qt::MatchExactly|Qt::MatchRecursive, 0); - QCOMPARE(matches.count(), 0); + QCOMPARE(matches.size(), 0); matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, -1); - QCOMPARE(matches.count(), 0); + QCOMPARE(matches.size(), 0); matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 1); - QCOMPARE(matches.count(), 0); + QCOMPARE(matches.size(), 0); } void tst_QStandardItemModel::getSetHeaderItem() @@ -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.count(), 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.count(), 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)); diff --git a/tests/auto/gui/kernel/qaction/tst_qaction.cpp b/tests/auto/gui/kernel/qaction/tst_qaction.cpp index cebcf9ca5a..930cee26b8 100644 --- a/tests/auto/gui/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/gui/kernel/qaction/tst_qaction.cpp @@ -209,11 +209,11 @@ void tst_QAction::setToolTip() QFETCH(QStringList, values); QFETCH(QStringList, expectedToolTips); - QCOMPARE(properties.count(), values.count()); - QCOMPARE(properties.count(), expectedToolTips.count()); + QCOMPARE(properties.size(), values.size()); + QCOMPARE(properties.size(), expectedToolTips.size()); QAction action(nullptr); - for (int i = 0; i < properties.count(); ++i) { + for (int i = 0; i < properties.size(); ++i) { const auto property = properties.at(i); const auto value = values.at(i); const auto expectedToolTip = expectedToolTips.at(i); @@ -272,19 +272,19 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup() // test without a group const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr)); QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered)); - QCOMPARE(spyWithoutGroup.count(), 0); + QCOMPARE(spyWithoutGroup.size(), 0); actionWithoutGroup->trigger(); // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); + QCOMPARE(spyWithoutGroup.size(), 1); // it is now a checkable checked action actionWithoutGroup->setCheckable(true); actionWithoutGroup->setChecked(true); spyWithoutGroup.clear(); - QCOMPARE(spyWithoutGroup.count(), 0); + QCOMPARE(spyWithoutGroup.size(), 0); actionWithoutGroup->trigger(); // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); + QCOMPARE(spyWithoutGroup.size(), 1); } void tst_QAction::setData() // QTBUG-62006 @@ -292,14 +292,14 @@ void tst_QAction::setData() // QTBUG-62006 QAction act(nullptr); QSignalSpy spy(&act, &QAction::changed); QCOMPARE(act.data(), QVariant()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); act.setData(QVariant()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); act.setData(-1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); act.setData(-1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QAction::setEnabledSetVisible() @@ -308,22 +308,22 @@ void tst_QAction::setEnabledSetVisible() QSignalSpy spy(&action, &QAction::enabledChanged); QVERIFY(action.isEnabled()); QVERIFY(action.isVisible()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); action.setVisible(false); QVERIFY(!action.isEnabled()); QVERIFY(!action.isVisible()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); action.setEnabled(false); QVERIFY(!action.isEnabled()); QVERIFY(!action.isVisible()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); action.setVisible(true); QVERIFY(!action.isEnabled()); QVERIFY(action.isVisible()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); action.resetEnabled(); QVERIFY(action.isEnabled()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QAction::setCheckabledSetChecked() @@ -334,37 +334,37 @@ void tst_QAction::setCheckabledSetChecked() QSignalSpy checkableSpy(&action, &QAction::checkableChanged); QVERIFY(!action.isCheckable()); QVERIFY(!action.isChecked()); - QCOMPARE(changedSpy.count(), 0); - QCOMPARE(checkedSpy.count(), 0); - QCOMPARE(checkableSpy.count(), 0); + QCOMPARE(changedSpy.size(), 0); + QCOMPARE(checkedSpy.size(), 0); + QCOMPARE(checkableSpy.size(), 0); action.setCheckable(true); QVERIFY(action.isCheckable()); QVERIFY(!action.isChecked()); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(checkedSpy.count(), 0); - QCOMPARE(checkableSpy.count(), 1); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(checkedSpy.size(), 0); + QCOMPARE(checkableSpy.size(), 1); action.setChecked(true); QVERIFY(action.isCheckable()); QVERIFY(action.isChecked()); - QCOMPARE(changedSpy.count(), 2); - QCOMPARE(checkedSpy.count(), 1); - QCOMPARE(checkableSpy.count(), 1); + QCOMPARE(changedSpy.size(), 2); + QCOMPARE(checkedSpy.size(), 1); + QCOMPARE(checkableSpy.size(), 1); action.setCheckable(false); QVERIFY(!action.isCheckable()); QVERIFY(!action.isChecked()); - QCOMPARE(changedSpy.count(), 3); - QCOMPARE(checkedSpy.count(), 2); - QCOMPARE(checkableSpy.count(), 2); + QCOMPARE(changedSpy.size(), 3); + QCOMPARE(checkedSpy.size(), 2); + QCOMPARE(checkableSpy.size(), 2); action.setCheckable(true); QVERIFY(action.isCheckable()); QVERIFY(action.isChecked()); - QCOMPARE(changedSpy.count(), 4); - QCOMPARE(checkedSpy.count(), 3); - QCOMPARE(checkableSpy.count(), 3); + QCOMPARE(changedSpy.size(), 4); + QCOMPARE(checkedSpy.size(), 3); + QCOMPARE(checkableSpy.size(), 3); } QTEST_MAIN(tst_QAction) diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 4163d072e0..d5150d97b1 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -124,7 +124,7 @@ public: operator bool() const { - if (m_timer.elapsed() && !m_spy.count()) + if (m_timer.elapsed() && !m_spy.size()) return true; m_spy.clear(); return false; @@ -166,11 +166,11 @@ void tst_QClipboard::testSignals() // Test the default mode signal. clipboard->setText(text); - QTRY_COMPARE(dataChangedSpy.count(), 1); - QCOMPARE(searchChangedSpy.count(), 0); - QCOMPARE(selectionChangedSpy.count(), 0); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QTRY_COMPARE(dataChangedSpy.size(), 1); + QCOMPARE(searchChangedSpy.size(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard); changedSpy.clear(); @@ -178,29 +178,29 @@ void tst_QClipboard::testSignals() // Test the selection mode signal. if (clipboard->supportsSelection()) { clipboard->setText(text, QClipboard::Selection); - QCOMPARE(selectionChangedSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QCOMPARE(selectionChangedSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection); } else { - QCOMPARE(selectionChangedSpy.count(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); } - QCOMPARE(dataChangedSpy.count(), 1); - QCOMPARE(searchChangedSpy.count(), 0); + QCOMPARE(dataChangedSpy.size(), 1); + QCOMPARE(searchChangedSpy.size(), 0); changedSpy.clear(); // Test the search mode signal. if (clipboard->supportsFindBuffer()) { clipboard->setText(text, QClipboard::FindBuffer); - QCOMPARE(searchChangedSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QCOMPARE(searchChangedSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer); } else { - QCOMPARE(searchChangedSpy.count(), 0); + QCOMPARE(searchChangedSpy.size(), 0); } - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); } #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) @@ -340,16 +340,16 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->clear(QClipboard::FindBuffer); if (QGuiApplication::clipboard()->supportsSelection()) - QCOMPARE(spySelection.count(), 1); + QCOMPARE(spySelection.size(), 1); else - QCOMPARE(spySelection.count(), 0); + QCOMPARE(spySelection.size(), 0); if (QGuiApplication::clipboard()->supportsFindBuffer()) - QCOMPARE(spyFindBuffer.count(), 1); + QCOMPARE(spyFindBuffer.size(), 1); else - QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyFindBuffer.size(), 0); - QTRY_COMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.size(), 1); // an other crash test data = new QMimeData; @@ -376,16 +376,16 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); if (QGuiApplication::clipboard()->supportsSelection()) - QCOMPARE(spySelection.count(), 1); + QCOMPARE(spySelection.size(), 1); else - QCOMPARE(spySelection.count(), 0); + QCOMPARE(spySelection.size(), 0); if (QGuiApplication::clipboard()->supportsFindBuffer()) - QCOMPARE(spyFindBuffer.count(), 1); + QCOMPARE(spyFindBuffer.size(), 1); else - QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyFindBuffer.size(), 0); - QTRY_COMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.size(), 1); } void tst_QClipboard::clearBeforeSetText() diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index d51b7af484..b3e50ea562 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -98,20 +98,20 @@ void tst_QGuiApplication::displayName() QGuiApplication::setApplicationName("The Core Application"); QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application")); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The Core Application")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QGuiApplication::setApplicationDisplayName("The GUI Application"); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application")); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QGuiApplication::setApplicationName("The Core Application 2"); QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application 2")); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application")); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QGuiApplication::setApplicationDisplayName("The GUI Application 2"); QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application 2")); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QGuiApplication::desktopFileName() @@ -222,12 +222,12 @@ void tst_QGuiApplication::focusObject() window1.setFocusObject(&obj1); QCOMPARE(app.focusObject(), &obj1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); window1.setFocusObject(&obj2); QCOMPARE(app.focusObject(), &obj2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); window2.setFocusObject(&obj3); @@ -236,12 +236,12 @@ void tst_QGuiApplication::focusObject() QVERIFY(QTest::qWaitForWindowExposed(&window2)); QTRY_COMPARE(app.focusWindow(), &window2); QCOMPARE(app.focusObject(), &obj3); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // focus change on unfocused window does not show spy.clear(); window1.setFocusObject(&obj1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(app.focusObject(), &obj3); } @@ -253,13 +253,13 @@ void tst_QGuiApplication::allWindows() QWindow *window2 = new QWindow(window1); QVERIFY(app.allWindows().contains(window1)); QVERIFY(app.allWindows().contains(window2)); - QCOMPARE(app.allWindows().count(), 2); + QCOMPARE(app.allWindows().size(), 2); delete window1; window1 = nullptr; window2 = nullptr; QVERIFY(!app.allWindows().contains(window2)); QVERIFY(!app.allWindows().contains(window1)); - QCOMPARE(app.allWindows().count(), 0); + QCOMPARE(app.allWindows().size(), 0); } void tst_QGuiApplication::topLevelWindows() @@ -270,13 +270,13 @@ void tst_QGuiApplication::topLevelWindows() QWindow *window2 = new QWindow(window1); QVERIFY(app.topLevelWindows().contains(window1)); QVERIFY(!app.topLevelWindows().contains(window2)); - QCOMPARE(app.topLevelWindows().count(), 1); + QCOMPARE(app.topLevelWindows().size(), 1); delete window1; window1 = nullptr; window2 = nullptr; QVERIFY(!app.topLevelWindows().contains(window2)); QVERIFY(!app.topLevelWindows().contains(window1)); - QCOMPARE(app.topLevelWindows().count(), 0); + QCOMPARE(app.topLevelWindows().size(), 0); } class ShowCloseShowWindow : public QWindow @@ -531,7 +531,7 @@ void tst_QGuiApplication::palette() QGuiApplication::setPalette(newPalette); QVERIFY(palettesMatch(QGuiApplication::palette(), newPalette)); #if QT_DEPRECATED_SINCE(6, 0) - QCOMPARE(signalSpy.count(), 1); + QCOMPARE(signalSpy.size(), 1); #endif QVERIFY(palettesMatch(signalSpy.at(0).at(0).value<QPalette>(), newPalette)); QCOMPARE(QGuiApplication::palette(), QPalette()); @@ -539,7 +539,7 @@ void tst_QGuiApplication::palette() QGuiApplication::setPalette(oldPalette); QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette)); #if QT_DEPRECATED_SINCE(6, 0) - QCOMPARE(signalSpy.count(), 2); + QCOMPARE(signalSpy.size(), 2); #endif QVERIFY(palettesMatch(signalSpy.at(1).at(0).value<QPalette>(), oldPalette)); QCOMPARE(QGuiApplication::palette(), QPalette()); @@ -547,7 +547,7 @@ void tst_QGuiApplication::palette() QGuiApplication::setPalette(oldPalette); QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette)); #if QT_DEPRECATED_SINCE(6, 0) - QCOMPARE(signalSpy.count(), 2); + QCOMPARE(signalSpy.size(), 2); #endif QCOMPARE(QGuiApplication::palette(), QPalette()); } @@ -564,17 +564,17 @@ void tst_QGuiApplication::font() QGuiApplication::setFont(newFont); QCOMPARE(QGuiApplication::font(), newFont); - QCOMPARE(signalSpy.count(), 1); + QCOMPARE(signalSpy.size(), 1); QCOMPARE(signalSpy.at(0).at(0), QVariant(newFont)); QGuiApplication::setFont(oldFont); QCOMPARE(QGuiApplication::font(), oldFont); - QCOMPARE(signalSpy.count(), 2); + QCOMPARE(signalSpy.size(), 2); QCOMPARE(signalSpy.at(1).at(0), QVariant(oldFont)); QGuiApplication::setFont(oldFont); QCOMPARE(QGuiApplication::font(), oldFont); - QCOMPARE(signalSpy.count(), 2); + QCOMPARE(signalSpy.size(), 2); } class BlockableWindow : public QWindow @@ -879,9 +879,9 @@ void tst_QGuiApplication::quitOnLastWindowClosed() app.exec(); - QCOMPARE(spyAboutToQuit.count(), 1); + QCOMPARE(spyAboutToQuit.size(), 1); // Should be around 10 if closing caused the quit - QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData()); + QVERIFY2(spyTimeout.size() < 15, QByteArray::number(spyTimeout.size()).constData()); } void tst_QGuiApplication::quitOnLastWindowClosedMulti() @@ -922,7 +922,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti() app.exec(); QVERIFY(!prematureQuit); - QCOMPARE(spyAboutToQuit.count(), 1); // fired only once + QCOMPARE(spyAboutToQuit.size(), 1); // fired only once } void tst_QGuiApplication::dontQuitOnLastWindowClosed() @@ -950,8 +950,8 @@ void tst_QGuiApplication::dontQuitOnLastWindowClosed() app.setQuitOnLastWindowClosed(true); // restore underlying static to default value - QCOMPARE(spyTimeout.count(), 1); // quit timer fired - QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted + QCOMPARE(spyTimeout.size(), 1); // quit timer fired + QCOMPARE(spyLastWindowClosed.size(), 1); // lastWindowClosed emitted } class QuitSpy : public QObject @@ -1153,12 +1153,12 @@ void tst_QGuiApplication::layoutDirection() QGuiApplication::setLayoutDirection(oldDirection); QCOMPARE(QGuiApplication::layoutDirection(), oldDirection); - QCOMPARE(signalSpy.count(), 1); + QCOMPARE(signalSpy.size(), 1); QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection)); QGuiApplication::setLayoutDirection(oldDirection); QCOMPARE(QGuiApplication::layoutDirection(), oldDirection); - QCOMPARE(signalSpy.count(), 1); + QCOMPARE(signalSpy.size(), 1); // with QGuiApplication instantiated, install a translator that gives us control class LayoutDirectionTranslator : public QTranslator @@ -1189,31 +1189,31 @@ void tst_QGuiApplication::layoutDirection() LayoutDirectionTranslator translator(oldDirection); QGuiApplication::installTranslator(&translator); QCOMPARE(QGuiApplication::layoutDirection(), translator.direction); - QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); } - QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); // ltrTranslator removed, no change + QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); // ltrTranslator removed, no change // install a new translator that changes the direction { LayoutDirectionTranslator translator(newDirection); QGuiApplication::installTranslator(&translator); QCOMPARE(QGuiApplication::layoutDirection(), translator.direction); - QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount); } // rtlTranslator removed - QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount); // override translation QGuiApplication::setLayoutDirection(newDirection); - QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount); { // this translator will be ignored LayoutDirectionTranslator translator(oldDirection); QGuiApplication::installTranslator(&translator); QCOMPARE(QGuiApplication::layoutDirection(), newDirection); - QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); } - QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); + QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); } diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp index 67c65f1160..ac42f0da30 100644 --- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp +++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp @@ -78,7 +78,7 @@ void tst_QInputDevice::multiSeatDevices() QWindowSystemInterface::registerInputDevice(new QPointingDevice("seat 2 mouse", 2010, QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic, QInputDevice::Capability::Position | QInputDevice::Capability::Hover, 1, 2, "seat 2", QPointingDeviceUniqueId(), this)); - QVERIFY(QInputDevice::devices().count() >= 4); + QVERIFY(QInputDevice::devices().size() >= 4); QVERIFY(QInputDevicePrivate::fromId(1010)); QVERIFY(QInputDevicePrivate::fromId(1010)->hasCapability(QInputDevice::Capability::Scroll)); QVERIFY(QInputDevicePrivate::fromId(2010)); diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 86669fde62..c562a5c362 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -125,7 +125,7 @@ void tst_qinputmethod::animating() QSignalSpy spy(qApp->inputMethod(), SIGNAL(animatingChanged())); m_platformInputContext.emitAnimatingChanged(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_qinputmethod::keyboarRectangle() @@ -137,7 +137,7 @@ void tst_qinputmethod::keyboarRectangle() QSignalSpy spy(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged())); m_platformInputContext.emitKeyboardRectChanged(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_qinputmethod::inputItemTransform() @@ -152,7 +152,7 @@ void tst_qinputmethod::inputItemTransform() qApp->inputMethod()->setInputItemTransform(transform); QCOMPARE(qApp->inputMethod()->inputItemTransform(), transform); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // reset qApp->inputMethod()->setInputItemTransform(QTransform()); diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp index 5420adca14..d7cc8a572c 100644 --- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp @@ -263,14 +263,14 @@ void tst_QMouseEvent::grabbers() auto firstEPD = devPriv->pointById(0); QCOMPARE(firstEPD->eventPoint.pressTimestamp(), testMouseWidget->pressTimestamp); QCOMPARE(firstEPD->exclusiveGrabber, grabExclusive ? testMouseWidget : nullptr); - QCOMPARE(firstEPD->passiveGrabbers.count(), grabPassive ? 1 : 0); + QCOMPARE(firstEPD->passiveGrabbers.size(), grabPassive ? 1 : 0); if (grabPassive) QCOMPARE(firstEPD->passiveGrabbers.first(), testMouseWidget); // Ensure that grabbers are forgotten after release delivery QTest::mouseRelease(testMouseWidget, Qt::LeftButton, Qt::KeyboardModifiers(), {10, 10}); QTRY_COMPARE(firstEPD->exclusiveGrabber, nullptr); - QCOMPARE(firstEPD->passiveGrabbers.count(), 0); + QCOMPARE(firstEPD->passiveGrabbers.size(), 0); } void tst_QMouseEvent::velocity() diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp index 9d85a31d5a..b537b211c1 100644 --- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp +++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp @@ -158,27 +158,27 @@ void tst_QScreen::orientationChange() QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation); QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation); - QCOMPARE(spy.count(), ++expectedSignalCount); + QCOMPARE(spy.size(), ++expectedSignalCount); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation); QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation); - QCOMPARE(spy.count(), ++expectedSignalCount); + QCOMPARE(spy.size(), ++expectedSignalCount); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation); QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation); - QCOMPARE(spy.count(), ++expectedSignalCount); + QCOMPARE(spy.size(), ++expectedSignalCount); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation); QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::InvertedPortraitOrientation); - QCOMPARE(spy.count(), ++expectedSignalCount); + QCOMPARE(spy.size(), ++expectedSignalCount); QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation); QWindowSystemInterface::flushWindowSystemEvents(); QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation); - QCOMPARE(spy.count(), ++expectedSignalCount); + QCOMPARE(spy.size(), ++expectedSignalCount); } void tst_QScreen::grabWindow_data() diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 200b7a5f51..a6047d80bf 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -732,7 +732,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.touchBeginPoints.size(), 1); QCOMPARE(touchWidget.timestamp, timestamp); QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); QCOMPARE(touchBeginPoint.id(), 0); @@ -762,7 +762,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 1); QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); QCOMPARE(touchUpdatePoint.id(), 0); QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); @@ -790,7 +790,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchEndPoints.count(), 1); + QCOMPARE(touchWidget.touchEndPoints.size(), 1); QEventPoint touchEndPoint = touchWidget.touchEndPoints.first(); QCOMPARE(touchEndPoint.id(), 0); QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); @@ -859,8 +859,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QVERIFY(rightWidget.seenTouchBegin); QVERIFY(!rightWidget.seenTouchUpdate); QVERIFY(!rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchBeginPoints.count(), 1); - QCOMPARE(rightWidget.touchBeginPoints.count(), 1); + QCOMPARE(leftWidget.touchBeginPoints.size(), 1); + QCOMPARE(rightWidget.touchBeginPoints.size(), 1); const int touchPointId0 = 0; const int touchPointId1 = touchPointId0 + 1; { @@ -907,8 +907,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QVERIFY(rightWidget.seenTouchBegin); QVERIFY(rightWidget.seenTouchUpdate); QVERIFY(!rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchUpdatePoints.count(), 1); - QCOMPARE(rightWidget.touchUpdatePoints.count(), 1); + QCOMPARE(leftWidget.touchUpdatePoints.size(), 1); + QCOMPARE(rightWidget.touchUpdatePoints.size(), 1); { const QEventPoint &leftTouchPoint = leftWidget.touchUpdatePoints.first(); QCOMPARE(leftTouchPoint.id(), touchPointId0); @@ -953,8 +953,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QVERIFY(rightWidget.seenTouchBegin); QVERIFY(rightWidget.seenTouchUpdate); QVERIFY(rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchEndPoints.count(), 1); - QCOMPARE(rightWidget.touchEndPoints.count(), 1); + QCOMPARE(leftWidget.touchEndPoints.size(), 1); + QCOMPARE(rightWidget.touchEndPoints.size(), 1); { const QEventPoint &leftTouchPoint = leftWidget.touchEndPoints.first(); QCOMPARE(leftTouchPoint.id(), touchPointId0); @@ -1012,7 +1012,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.touchBeginPoints.size(), 1); QCOMPARE(touchWidget.timestamp, timestamp); QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); QCOMPARE(touchBeginPoint.id(), 1); @@ -1027,7 +1027,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.touchBeginPoints.size(), 1); QCOMPARE(touchWidget.timestamp, timestamp); touchBeginPoint = touchWidget.touchBeginPoints[0]; QCOMPARE(touchBeginPoint.id(), 10); @@ -1042,7 +1042,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.touchBeginPoints.size(), 1); QCOMPARE(touchWidget.timestamp, timestamp); touchBeginPoint = touchWidget.touchBeginPoints[0]; QCOMPARE(touchBeginPoint.id(), 11); @@ -1058,7 +1058,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 1); QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); QCOMPARE(touchUpdatePoint.id(), 1); QCOMPARE(touchUpdatePoint.state(), QEventPoint::State::Updated); @@ -1073,7 +1073,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchEndPoints.count(), 1); + QCOMPARE(touchWidget.touchEndPoints.size(), 1); QEventPoint touchEndPoint = touchWidget.touchEndPoints.first(); QCOMPARE(touchEndPoint.id(), 1); QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released); @@ -1098,7 +1098,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 2); QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 10); QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 11); @@ -1113,7 +1113,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchEndPoints.count(), 1); + QCOMPARE(touchWidget.touchEndPoints.size(), 1); touchEndPoint = touchWidget.touchEndPoints.first(); QCOMPARE(touchEndPoint.id(), 11); QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released); @@ -1188,8 +1188,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QVERIFY(!rightWidget.seenTouchBegin); QVERIFY(!rightWidget.seenTouchUpdate); QVERIFY(!rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchBeginPoints.count(), 2); - QCOMPARE(rightWidget.touchBeginPoints.count(), 0); + QCOMPARE(leftWidget.touchBeginPoints.size(), 2); + QCOMPARE(rightWidget.touchBeginPoints.size(), 0); { QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0); qCDebug(lcTests) << "lastNormalizedPositions after press" << leftWidget.lastNormalizedPositions; @@ -1250,8 +1250,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QVERIFY(!rightWidget.seenTouchBegin); QVERIFY(!rightWidget.seenTouchUpdate); QVERIFY(!rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchUpdatePoints.count(), 2); - QCOMPARE(rightWidget.touchUpdatePoints.count(), 0); + QCOMPARE(leftWidget.touchUpdatePoints.size(), 2); + QCOMPARE(rightWidget.touchUpdatePoints.size(), 0); { QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0); qCDebug(lcTests) << "lastNormalizedPositions after update" << leftWidget.lastNormalizedPositions; @@ -1312,8 +1312,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QVERIFY(!rightWidget.seenTouchBegin); QVERIFY(!rightWidget.seenTouchUpdate); QVERIFY(!rightWidget.seenTouchEnd); - QCOMPARE(leftWidget.touchEndPoints.count(), 2); - QCOMPARE(rightWidget.touchEndPoints.count(), 0); + QCOMPARE(leftWidget.touchEndPoints.size(), 2); + QCOMPARE(rightWidget.touchEndPoints.size(), 0); { QEventPoint leftTouchPoint = leftWidget.touchEndPoints.at(0); qCDebug(lcTests) << "lastNormalizedPositions after release" << leftWidget.lastNormalizedPositions; @@ -1396,16 +1396,16 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchBeginPoints.count(), 2); + QCOMPARE(touchWidget.touchBeginPoints.size(), 2); - for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) { + for (int i = 0; i < touchWidget.touchBeginPoints.size(); ++i) { QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i); QCOMPARE(touchBeginPoint.id(), i); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state()); } // moving the point should translate to TouchUpdate - for (int i = 0; i < rawTouchPoints.count(); ++i) { + for (int i = 0; i < rawTouchPoints.size(); ++i) { auto &p = rawTouchPoints[i]; QMutableEventPoint::setState(p, QEventPoint::State::Updated); QMutableEventPoint::setGlobalPosition(p, p.globalPosition() + delta); @@ -1417,7 +1417,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 2); QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), 0); QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1); @@ -1432,7 +1432,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QCOMPARE(touchWidget.seenTouchEnd, false); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 2); QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1); @@ -1446,7 +1446,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 2); QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42); @@ -1460,7 +1460,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(touchWidget.seenTouchEnd); - QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.size(), 2); QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42); } @@ -1824,25 +1824,25 @@ void tst_QTouchEvent::testQGuiAppDelivery() // Now the real thing. QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin QCoreApplication::processEvents(); - QCOMPARE(filter.d.count(), 1); + QCOMPARE(filter.d.size(), 1); QCOMPARE(filter.d.contains(touchScreenDevice), true); - QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); + QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1); QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); points[0].state = QEventPoint::State::Updated; QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate QCoreApplication::processEvents(); - QCOMPARE(filter.d.count(), 1); + QCOMPARE(filter.d.size(), 1); QCOMPARE(filter.d.contains(touchScreenDevice), true); - QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2); + QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 2); QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate); points[0].state = QEventPoint::State::Released; QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd QCoreApplication::processEvents(); - QCOMPARE(filter.d.count(), 1); + QCOMPARE(filter.d.size(), 1); QCOMPARE(filter.d.contains(touchScreenDevice), true); - QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3); + QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 3); QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd); } @@ -1885,8 +1885,8 @@ void tst_QTouchEvent::testMultiDevice() QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin); - QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); - QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); + QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1); + QCOMPARE(filter.d.value(deviceTwo).points.size(), 2); QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).globalPosition(), area0.center()); // This fails because QGuiApplicationPrivate::processTouchEvent() sends synth-mouse events @@ -1941,7 +1941,7 @@ void tst_QTouchEvent::grabbers() // Ensure that grabbers are persistent between events, within the stored touchpoints QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, grabExclusive ? &w : nullptr); - QCOMPARE(devPriv->pointById(0)->passiveGrabbers.count(), grabPassive ? 1 : 0); + QCOMPARE(devPriv->pointById(0)->passiveGrabbers.size(), grabPassive ? 1 : 0); if (grabPassive) QCOMPARE(devPriv->pointById(0)->passiveGrabbers.first(), &w); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index bb0f9817c3..368fb07b23 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -988,7 +988,7 @@ public: } touchEventType = event->type(); QList<QTouchEvent::TouchPoint> points = event->points(); - for (int i = 0; i < points.count(); ++i) { + for (int i = 0; i < points.size(); ++i) { const auto &point = points.at(i); switch (point.state()) { case QEventPoint::State::Pressed: @@ -1505,7 +1505,7 @@ void tst_QWindow::orientation() QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation))); window.reportContentOrientationChange(Qt::LandscapeOrientation); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QWindow::sizes() @@ -1524,40 +1524,40 @@ void tst_QWindow::sizes() QCOMPARE(window.minimumHeight(), 0); QCOMPARE(window.minimumSize(), QSize(10, 0)); QCOMPARE(window.maximumSize(), oldMaximum); - QCOMPARE(minimumWidthSpy.count(), 1); - QCOMPARE(minimumHeightSpy.count(), 0); - QCOMPARE(maximumWidthSpy.count(), 0); - QCOMPARE(maximumHeightSpy.count(), 0); + QCOMPARE(minimumWidthSpy.size(), 1); + QCOMPARE(minimumHeightSpy.size(), 0); + QCOMPARE(maximumWidthSpy.size(), 0); + QCOMPARE(maximumHeightSpy.size(), 0); window.setMinimumHeight(10); QCOMPARE(window.minimumWidth(), 10); QCOMPARE(window.minimumHeight(), 10); QCOMPARE(window.minimumSize(), QSize(10, 10)); QCOMPARE(window.maximumSize(), oldMaximum); - QCOMPARE(minimumWidthSpy.count(), 1); - QCOMPARE(minimumHeightSpy.count(), 1); - QCOMPARE(maximumWidthSpy.count(), 0); - QCOMPARE(maximumHeightSpy.count(), 0); + QCOMPARE(minimumWidthSpy.size(), 1); + QCOMPARE(minimumHeightSpy.size(), 1); + QCOMPARE(maximumWidthSpy.size(), 0); + QCOMPARE(maximumHeightSpy.size(), 0); window.setMaximumWidth(100); QCOMPARE(window.maximumWidth(), 100); QCOMPARE(window.maximumHeight(), oldMaximum.height()); QCOMPARE(window.minimumSize(), QSize(10, 10)); QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height())); - QCOMPARE(minimumWidthSpy.count(), 1); - QCOMPARE(minimumHeightSpy.count(), 1); - QCOMPARE(maximumWidthSpy.count(), 1); - QCOMPARE(maximumHeightSpy.count(), 0); + QCOMPARE(minimumWidthSpy.size(), 1); + QCOMPARE(minimumHeightSpy.size(), 1); + QCOMPARE(maximumWidthSpy.size(), 1); + QCOMPARE(maximumHeightSpy.size(), 0); window.setMaximumHeight(100); QCOMPARE(window.maximumWidth(), 100); QCOMPARE(window.maximumHeight(), 100); QCOMPARE(window.minimumSize(), QSize(10, 10)); QCOMPARE(window.maximumSize(), QSize(100, 100)); - QCOMPARE(minimumWidthSpy.count(), 1); - QCOMPARE(minimumHeightSpy.count(), 1); - QCOMPARE(maximumWidthSpy.count(), 1); - QCOMPARE(maximumHeightSpy.count(), 1); + QCOMPARE(minimumWidthSpy.size(), 1); + QCOMPARE(minimumHeightSpy.size(), 1); + QCOMPARE(maximumWidthSpy.size(), 1); + QCOMPARE(maximumHeightSpy.size(), 1); } class CloseOnCloseEventWindow : public QWindow @@ -1789,25 +1789,25 @@ void tst_QWindow::windowModality() QCOMPARE(window.modality(), Qt::NonModal); window.setModality(Qt::NonModal); QCOMPARE(window.modality(), Qt::NonModal); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); window.setModality(Qt::WindowModal); QCOMPARE(window.modality(), Qt::WindowModal); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); window.setModality(Qt::WindowModal); QCOMPARE(window.modality(), Qt::WindowModal); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); window.setModality(Qt::ApplicationModal); QCOMPARE(window.modality(), Qt::ApplicationModal); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); window.setModality(Qt::ApplicationModal); QCOMPARE(window.modality(), Qt::ApplicationModal); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); window.setModality(Qt::NonModal); QCOMPARE(window.modality(), Qt::NonModal); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QWindow::inputReentrancy() @@ -1990,32 +1990,32 @@ void tst_QWindow::visibility() QVERIFY(window.isVisible()); QVERIFY(window.visibility() != QWindow::Hidden); QVERIFY(window.visibility() != QWindow::AutomaticVisibility); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); window.setVisibility(QWindow::Hidden); QVERIFY(!window.isVisible()); QCOMPARE(window.visibility(), QWindow::Hidden); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); window.setVisibility(QWindow::FullScreen); QVERIFY(window.isVisible()); QCOMPARE(window.windowState(), Qt::WindowFullScreen); QCOMPARE(window.visibility(), QWindow::FullScreen); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen); spy.clear(); window.setWindowState(Qt::WindowNoState); QCOMPARE(window.visibility(), QWindow::Windowed); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState); spy.clear(); window.setVisible(false); QCOMPARE(window.visibility(), QWindow::Hidden); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 1a677ad445..eb705a0219 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -5181,7 +5181,7 @@ void tst_QPainter::drawPolyline() p.setPen(pen); QVERIFY(p.pen().isCosmetic()); if (r) { - for (int i = 0; i < points.count()-1; i++) { + for (int i = 0; i < points.size()-1; i++) { p.drawLine(points.at(i), points.at(i+1)); } } else { diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp index 87dda161d2..512381ab95 100644 --- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp +++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp @@ -168,8 +168,8 @@ void tst_QPolygon::swap() QPolygon p2(QList<QPoint>() << QPoint(0, 0) << QPoint(0, 10) << QPoint(10, 10) << QPoint(10, 0)); p1.swap(p2); - QCOMPARE(p1.count(),4); - QCOMPARE(p2.count(),3); + QCOMPARE(p1.size(),4); + QCOMPARE(p2.size(),3); } void tst_QPolygon::intersections_data() diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp index 4ab2d1adb3..037964f42b 100644 --- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp +++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp @@ -126,7 +126,7 @@ void tst_QAbstractTextDocumentLayout::anchorAt() QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); QTextBlock firstBlock = doc.begin(); QTextLayout *layout = firstBlock.layout(); - layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + layout->setPreeditArea(doc.toPlainText().size(), "xxx"); doc.setPageSize(QSizeF(1000, 1000)); QFontMetrics metrics(layout->font()); @@ -156,7 +156,7 @@ void tst_QAbstractTextDocumentLayout::imageAt() QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); QTextBlock firstBlock = doc.begin(); QTextLayout *layout = firstBlock.layout(); - layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + layout->setPreeditArea(doc.toPlainText().size(), "xxx"); doc.setPageSize(QSizeF(1000, 1000)); QFontMetrics metrics(layout->font()); @@ -181,7 +181,7 @@ void tst_QAbstractTextDocumentLayout::formatAt() QAbstractTextDocumentLayout *documentLayout = doc.documentLayout(); QTextBlock firstBlock = doc.begin(); QTextLayout *layout = firstBlock.layout(); - layout->setPreeditArea(doc.toPlainText().length(), "xxx"); + layout->setPreeditArea(doc.toPlainText().size(), "xxx"); doc.setPageSize(QSizeF(1000, 1000)); QFontMetrics metrics(layout->font()); diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 3b20068f17..f5d544d1e7 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -126,7 +126,7 @@ static const char *tokenName(QCss::TokenType t) static void debug(const QList<QCss::Symbol> &symbols, int index = -1) { qDebug() << "all symbols:"; - for (int i = 0; i < symbols.count(); ++i) + for (int i = 0; i < symbols.size(); ++i) qDebug() << '(' << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem(); if (index != -1) qDebug() << "failure at index" << index; @@ -144,10 +144,10 @@ void tst_QCssParser::scanner() QList<QCss::Symbol> symbols; QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols); - QVERIFY(symbols.count() > 1); + QVERIFY(symbols.size() > 1); QCOMPARE(symbols.last().token, QCss::S); QCOMPARE(symbols.last().lexem(), QLatin1String("\n")); - symbols.remove(symbols.count() - 1, 1); + symbols.remove(symbols.size() - 1, 1); QFile outputFile(output); QVERIFY(outputFile.open(QIODevice::ReadOnly|QIODevice::Text)); @@ -159,14 +159,14 @@ void tst_QCssParser::scanner() lines.append(line); } - if (lines.count() != symbols.count()) { + if (lines.size() != symbols.size()) { debug(symbols); - QCOMPARE(lines.count(), symbols.count()); + QCOMPARE(lines.size(), symbols.size()); } - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { QStringList l = lines.at(i).split(QChar::fromLatin1('|')); - QCOMPARE(l.count(), 2); + QCOMPARE(l.size(), 2); const QString expectedToken = l.at(0); const QString expectedLexem = l.at(1); QString actualToken = QString::fromLatin1(tokenName(symbols.at(i).token)); @@ -350,9 +350,9 @@ void tst_QCssParser::expr() QVERIFY(parser.testExpr()); QCOMPARE(parser.parseExpr(&values), parseSuccess); if (parseSuccess) { - QCOMPARE(values.count(), expectedValues.count()); + QCOMPARE(values.size(), expectedValues.size()); - for (int i = 0; i < values.count(); ++i) { + for (int i = 0; i < values.size(); ++i) { QCOMPARE(int(values.at(i).type), int(expectedValues.at(i).type)); QCOMPARE(values.at(i).variant, expectedValues.at(i).variant); } @@ -371,7 +371,7 @@ void tst_QCssParser::import() QVERIFY(parser.testImport()); QVERIFY(parser.parseImport(&rule)); QCOMPARE(rule.href, QString("www.kde.org")); - QCOMPARE(rule.media.count(), 2); + QCOMPARE(rule.media.size(), 2); QCOMPARE(rule.media.at(0), QString("print")); QCOMPARE(rule.media.at(1), QString("screen")); } @@ -382,7 +382,7 @@ void tst_QCssParser::media() QVERIFY(parser.testMedia()); QCss::MediaRule rule; QVERIFY(parser.parseMedia(&rule)); - QCOMPARE(rule.media.count(), 2); + QCOMPARE(rule.media.size(), 2); QCOMPARE(rule.media.at(0), QString("print")); QCOMPARE(rule.media.at(1), QString("screen")); QVERIFY(rule.styleRules.isEmpty()); @@ -405,8 +405,8 @@ void tst_QCssParser::ruleset() QVERIFY(parser.testRuleset()); QCss::StyleRule rule; QVERIFY(parser.parseRuleset(&rule)); - QCOMPARE(rule.selectors.count(), 1); - QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1); + QCOMPARE(rule.selectors.size(), 1); + QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1); QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p")); QVERIFY(rule.declarations.isEmpty()); } @@ -416,10 +416,10 @@ void tst_QCssParser::ruleset() QVERIFY(parser.testRuleset()); QCss::StyleRule rule; QVERIFY(parser.parseRuleset(&rule)); - QCOMPARE(rule.selectors.count(), 2); - QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1); + QCOMPARE(rule.selectors.size(), 2); + QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1); QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p")); - QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1); + QCOMPARE(rule.selectors.at(1).basicSelectors.size(), 1); QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).elementName, QString("div")); QVERIFY(rule.declarations.isEmpty()); } @@ -429,14 +429,14 @@ void tst_QCssParser::ruleset() QVERIFY(parser.testRuleset()); QCss::StyleRule rule; QVERIFY(parser.parseRuleset(&rule)); - QCOMPARE(rule.selectors.count(), 2); + QCOMPARE(rule.selectors.size(), 2); - QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1); - QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.count(), 1); + QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1); + QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.size(), 1); QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.at(0).name, QString("before")); - QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1); - QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.count(), 1); + QCOMPARE(rule.selectors.at(1).basicSelectors.size(), 1); + QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.size(), 1); QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.at(0).name, QString("after")); QVERIFY(rule.declarations.isEmpty()); @@ -688,21 +688,21 @@ void tst_QCssParser::selector() QCss::Selector selector; QVERIFY(parser.parseSelector(&selector)); - QCOMPARE(selector.basicSelectors.count(), expectedSelector.basicSelectors.count()); - for (int i = 0; i < selector.basicSelectors.count(); ++i) { + QCOMPARE(selector.basicSelectors.size(), expectedSelector.basicSelectors.size()); + for (int i = 0; i < selector.basicSelectors.size(); ++i) { const QCss::BasicSelector sel = selector.basicSelectors.at(i); const QCss::BasicSelector expectedSel = expectedSelector.basicSelectors.at(i); QCOMPARE(sel.elementName, expectedSel.elementName); QCOMPARE(int(sel.relationToNext), int(expectedSel.relationToNext)); - QCOMPARE(sel.pseudos.count(), expectedSel.pseudos.count()); - for (int i = 0; i < sel.pseudos.count(); ++i) { + QCOMPARE(sel.pseudos.size(), expectedSel.pseudos.size()); + for (int i = 0; i < sel.pseudos.size(); ++i) { QCOMPARE(sel.pseudos.at(i).name, expectedSel.pseudos.at(i).name); QCOMPARE(sel.pseudos.at(i).function, expectedSel.pseudos.at(i).function); } - QCOMPARE(sel.attributeSelectors.count(), expectedSel.attributeSelectors.count()); - for (int i = 0; i < sel.attributeSelectors.count(); ++i) { + QCOMPARE(sel.attributeSelectors.size(), expectedSel.attributeSelectors.size()); + for (int i = 0; i < sel.attributeSelectors.size(); ++i) { QCOMPARE(sel.attributeSelectors.at(i).name, expectedSel.attributeSelectors.at(i).name); QCOMPARE(sel.attributeSelectors.at(i).value, expectedSel.attributeSelectors.at(i).value); QCOMPARE(int(sel.attributeSelectors.at(i).valueMatchCriterium), int(expectedSel.attributeSelectors.at(i).valueMatchCriterium)); @@ -760,13 +760,13 @@ void tst_QCssParser::malformedDeclarations() QCss::StyleRule rule; QVERIFY(parser.parseRuleset(&rule)); - QCOMPARE(rule.selectors.count(), 1); - QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1); + QCOMPARE(rule.selectors.size(), 1); + QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1); QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p")); - QVERIFY(rule.declarations.count() >= 1); + QVERIFY(rule.declarations.size() >= 1); QCOMPARE(int(rule.declarations.last().d->propertyId), int(QCss::Color)); - QCOMPARE(rule.declarations.last().d->values.count(), 1); + QCOMPARE(rule.declarations.last().d->values.size(), 1); QCOMPARE(int(rule.declarations.last().d->values.at(0).type), int(QCss::Value::Identifier)); QCOMPARE(rule.declarations.last().d->values.at(0).variant.toString(), QString("green")); } @@ -786,17 +786,17 @@ void tst_QCssParser::invalidAtKeywords() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : *sheet.nameIndex.begin(); - QCOMPARE(rule.selectors.count(), 1); - QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1); + QCOMPARE(rule.selectors.size(), 1); + QCOMPARE(rule.selectors.at(0).basicSelectors.size(), 1); QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("h1")); - QCOMPARE(rule.declarations.count(), 1); + QCOMPARE(rule.declarations.size(), 1); QCOMPARE(int(rule.declarations.at(0).d->propertyId), int(QCss::Color)); - QCOMPARE(rule.declarations.at(0).d->values.count(), 1); + QCOMPARE(rule.declarations.at(0).d->values.size(), 1); QCOMPARE(int(rule.declarations.at(0).d->values.at(0).type), int(QCss::Value::Identifier)); QCOMPARE(rule.declarations.at(0).d->values.at(0).variant.toString(), QString("blue")); } @@ -1141,9 +1141,9 @@ void tst_QCssParser::styleSelector() QList<QCss::Declaration> decls = testSelector.declarationsForNode(n); if (match) { - QCOMPARE(decls.count(), 1); + QCOMPARE(decls.size(), 1); QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::BackgroundColor)); - QCOMPARE(decls.at(0).d->values.count(), 1); + QCOMPARE(decls.at(0).d->values.size(), 1); QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier)); QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green")); } else { @@ -1183,11 +1183,11 @@ void tst_QCssParser::specificity() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count() + sheet.idIndex.count() , 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size() + sheet.idIndex.size() , 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : (!sheet.nameIndex.isEmpty()) ? *sheet.nameIndex.begin() : *sheet.idIndex.begin(); - QCOMPARE(rule.selectors.count(), 1); + QCOMPARE(rule.selectors.size(), 1); QTEST(rule.selectors.at(0).specificity(), "specificity"); } @@ -1236,15 +1236,15 @@ void tst_QCssParser::specificitySort() n.ptr = &e; QList<QCss::Declaration> decls = testSelector.declarationsForNode(n); - QCOMPARE(decls.count(), 2); + QCOMPARE(decls.size(), 2); QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::Color)); - QCOMPARE(decls.at(0).d->values.count(), 1); + QCOMPARE(decls.at(0).d->values.size(), 1); QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier)); QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green")); QCOMPARE(int(decls.at(1).d->propertyId), int(QCss::Color)); - QCOMPARE(decls.at(1).d->values.count(), 1); + QCOMPARE(decls.at(1).d->values.size(), 1); QCOMPARE(int(decls.at(1).d->values.at(0).type), int(QCss::Value::Identifier)); QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), QString("red")); } @@ -1319,7 +1319,7 @@ void tst_QCssParser::rulesForNode() QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n); QList<QCss::Declaration> decls; - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const QCss::Selector &selector = rules.at(i).selectors.at(0); quint64 negated = 0; quint64 cssClass = selector.pseudoClass(&negated); @@ -1328,7 +1328,7 @@ void tst_QCssParser::rulesForNode() decls += rules.at(i).declarations; } - QCOMPARE(decls.count(), declCount); + QCOMPARE(decls.size(), declCount); if (declCount > 0) QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0); @@ -1455,14 +1455,14 @@ void tst_QCssParser::pseudoElement() n.ptr = &e; QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n); QList<QCss::Declaration> decls; - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const QCss::Selector& selector = rules.at(i).selectors.at(0); if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0) continue; decls += rules.at(i).declarations; } - QCOMPARE(decls.count(), declCount); + QCOMPARE(decls.size(), declCount); } void tst_QCssParser::gradient_data() @@ -1596,7 +1596,7 @@ void tst_QCssParser::extractFontFamily() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : *sheet.nameIndex.begin(); @@ -1654,7 +1654,7 @@ void tst_QCssParser::extractBorder() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : *sheet.nameIndex.begin(); const QList<QCss::Declaration> decls = rule.declarations; @@ -1684,7 +1684,7 @@ void tst_QCssParser::noTextDecoration() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : *sheet.nameIndex.begin(); const QList<QCss::Declaration> decls = rule.declarations; @@ -1709,7 +1709,7 @@ void tst_QCssParser::quotedAndUnquotedIdentifiers() QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); - QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1); + QCOMPARE(sheet.styleRules.size() + sheet.nameIndex.size(), 1); QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) : *sheet.nameIndex.begin(); const QList<QCss::Declaration> decls = rule.declarations; diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 4b3d4bfddb..6d86eb32fe 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -357,15 +357,15 @@ void tst_QFont::insertAndRemoveSubstitutions() // inserting Foo QFont::insertSubstitution("BogusFontFamily", "Foo"); - QCOMPARE(QFont::substitutes("BogusFontFamily").count(), 1); - QCOMPARE(QFont::substitutes("bogusfontfamily").count(), 1); + QCOMPARE(QFont::substitutes("BogusFontFamily").size(), 1); + QCOMPARE(QFont::substitutes("bogusfontfamily").size(), 1); // inserting Bar and Baz QStringList moreFonts; moreFonts << "Bar" << "Baz"; QFont::insertSubstitutions("BogusFontFamily", moreFonts); - QCOMPARE(QFont::substitutes("BogusFontFamily").count(), 3); - QCOMPARE(QFont::substitutes("bogusfontfamily").count(), 3); + QCOMPARE(QFont::substitutes("BogusFontFamily").size(), 3); + QCOMPARE(QFont::substitutes("bogusfontfamily").size(), 3); QFont::removeSubstitutions("BogusFontFamily"); // make sure it is empty again diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 9c56d9b2d2..665ee75a35 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -236,7 +236,7 @@ void tst_QFontDatabase::addAppFont() QCOMPARE(id, -1); return; #endif - QCOMPARE(fontDbChangedSpy.count(), 1); + QCOMPARE(fontDbChangedSpy.size(), 1); if (id == -1) QSKIP("Skip the test since app fonts are not supported on this system"); @@ -245,9 +245,9 @@ void tst_QFontDatabase::addAppFont() const QStringList newFamilies = QFontDatabase::families(); QVERIFY(!newFamilies.isEmpty()); - QVERIFY(newFamilies.count() >= oldFamilies.count()); + QVERIFY(newFamilies.size() >= oldFamilies.size()); - for (int i = 0; i < addedFamilies.count(); ++i) { + for (int i = 0; i < addedFamilies.size(); ++i) { QString family = addedFamilies.at(i); QVERIFY(newFamilies.contains(family)); QFont qfont(family); @@ -256,9 +256,9 @@ void tst_QFontDatabase::addAppFont() } QVERIFY(QFontDatabase::removeApplicationFont(id)); - QCOMPARE(fontDbChangedSpy.count(), 2); + QCOMPARE(fontDbChangedSpy.size(), 2); - QVERIFY(QFontDatabase::families().count() <= oldFamilies.count()); + QVERIFY(QFontDatabase::families().size() <= oldFamilies.size()); } void tst_QFontDatabase::addTwoAppFontsFromFamily() diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 0e90572709..8b203f439e 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -96,7 +96,7 @@ void tst_QRawFont::initTestCase() if (testFont.isEmpty() || testFontBoldItalic.isEmpty()) QFAIL("qrawfont unittest font files not found!"); - if (QFontDatabase::families().count() == 0) + if (QFontDatabase::families().size() == 0) QSKIP("No fonts available!!!"); } diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index 202d07ea1e..2d92d49f4f 100644 --- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -100,7 +100,7 @@ public: virtual void highlightBlock(const QString &text) override { - for (int i = 0; i < formats.count(); ++i) { + for (int i = 0; i < formats.size(); ++i) { const QTextLayout::FormatRange &range = formats.at(i); setFormat(range.start, range.length, range.format); } @@ -161,7 +161,7 @@ public: commentFormat.setForeground(Qt::darkGreen); commentFormat.setFontWeight(QFont::StyleItalic); commentFormat.setFontFixedPitch(true); - int textLength = text.length(); + int textLength = text.size(); if (text.startsWith(QLatin1Char(';'))){ // The entire line is a comment @@ -414,7 +414,7 @@ void tst_QSyntaxHighlighter::preservePreeditArea() QCOMPARE(hl->callCount, 1); formats = layout->formats(); - QCOMPARE(formats.count(), 3); + QCOMPARE(formats.size(), 3); range = formats.at(0); @@ -493,7 +493,7 @@ void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight() QSignalSpy contentsChangedSpy(doc, SIGNAL(contentsChanged())); cursor.insertText("Hello World"); - QCOMPARE(contentsChangedSpy.count(), 1); + QCOMPARE(contentsChangedSpy.size(), 1); QVERIFY(hl->highlighted); QVERIFY(lout->documentChangedCalled); } diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp index cc6722af40..639e2e277f 100644 --- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp @@ -1754,26 +1754,26 @@ void tst_QTextCursor::update_data() QTest::newRow("removeInsideSelection") << text << /*position*/ 0 - << /*anchor*/ int(text.length()) + << /*anchor*/ int(text.size()) // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove << /*expectedPosition*/ 0 - << /*expectedAnchor*/ int(text.length() - charsToDelete) + << /*expectedAnchor*/ int(text.size() - charsToDelete) ; text = "Hello big world"; charsToDelete = 3; QTest::newRow("removeInsideSelectionWithSwappedAnchorAndPosition") << text - << /*position*/ int(text.length()) + << /*position*/ int(text.size()) << /*anchor*/ 0 // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove - << /*expectedPosition*/ int(text.length() - charsToDelete) + << /*expectedPosition*/ int(text.size() - charsToDelete) << /*expectedAnchor*/ 0 ; @@ -1784,13 +1784,13 @@ void tst_QTextCursor::update_data() QTest::newRow("replaceInsideSelection") << text << /*position*/ 0 - << /*anchor*/ int(text.length()) + << /*anchor*/ int(text.size()) // delete 'big' ... << 6 << 6 + charsToDelete << textToInsert // ... and replace 'big' with 'small' << /*expectedPosition*/ 0 - << /*expectedAnchor*/ int(text.length() - charsToDelete + textToInsert.length()) + << /*expectedAnchor*/ int(text.size() - charsToDelete + textToInsert.size()) ; text = "Hello big world"; @@ -1798,13 +1798,13 @@ void tst_QTextCursor::update_data() textToInsert = "small"; QTest::newRow("replaceInsideSelectionWithSwappedAnchorAndPosition") << text - << /*position*/ int(text.length()) + << /*position*/ int(text.size()) << /*anchor*/ 0 // delete 'big' ... << 6 << 6 + charsToDelete << textToInsert // ... and replace 'big' with 'small' - << /*expectedPosition*/ int(text.length() - charsToDelete + textToInsert.length()) + << /*expectedPosition*/ int(text.size() - charsToDelete + textToInsert.size()) << /*expectedAnchor*/ 0 ; @@ -1813,14 +1813,14 @@ void tst_QTextCursor::update_data() charsToDelete = 3; QTest::newRow("removeBeforeSelection") << text - << /*position*/ int(text.length() - 5) - << /*anchor*/ int(text.length()) + << /*position*/ int(text.size() - 5) + << /*anchor*/ int(text.size()) // delete 'big' << 6 << 6 + charsToDelete << QString() // don't insert anything, just remove - << /*expectedPosition*/ int(text.length() - 5 - charsToDelete) - << /*expectedAnchor*/ int(text.length() - charsToDelete) + << /*expectedPosition*/ int(text.size() - 5 - charsToDelete) + << /*expectedAnchor*/ int(text.size() - charsToDelete) ; text = "Hello big world"; diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index d10027b7a0..dc93c86829 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -465,17 +465,17 @@ void tst_QTextDocument::basicIsModifiedChecks() QVERIFY(!doc->isModified()); cursor.insertText("Hello World"); QVERIFY(doc->isModified()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(spy.takeFirst().at(0).toBool()); doc->undo(); QVERIFY(!doc->isModified()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!spy.takeFirst().at(0).toBool()); doc->redo(); QVERIFY(doc->isModified()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(spy.takeFirst().at(0).toBool()); } @@ -566,16 +566,16 @@ void tst_QTextDocument::noundo_basicIsModifiedChecks() QVERIFY(!doc->isModified()); cursor.insertText("Hello World"); QVERIFY(doc->isModified()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(spy.takeFirst().at(0).toBool()); doc->undo(); QVERIFY(doc->isModified()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); doc->redo(); QVERIFY(doc->isModified()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTextDocument::task240325() @@ -1945,7 +1945,7 @@ void tst_QTextDocument::toHtmlBodyBgColor() doc.rootFrame()->setFrameFormat(fmt); QString expectedHtml = htmlHead; - expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"#0000ff\""); + expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"#0000ff\""); expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>" + htmlTail; @@ -1965,7 +1965,7 @@ void tst_QTextDocument::toHtmlBodyBgColorRgba() doc.rootFrame()->setFrameFormat(fmt); QString expectedHtml = htmlHead; - expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"rgba(255,0,0,0.2)\""); + expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"rgba(255,0,0,0.2)\""); expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>" + htmlTail; @@ -1985,7 +1985,7 @@ void tst_QTextDocument::toHtmlBodyBgColorTransparent() doc.rootFrame()->setFrameFormat(fmt); QString expectedHtml = htmlHead; - expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"transparent\""); + expectedHtml.insert(htmlHead.size() - 2, " bgcolor=\"transparent\""); expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>" + htmlTail; @@ -2051,7 +2051,7 @@ void tst_QTextDocument::toHtmlDefaultFontSpacingProperties() doc.setDefaultFont(fnt); QString expectedOutput = htmlHead; - expectedOutput.insert(htmlHead.length() - 3, " letter-spacing:13px; word-spacing:15px;"); + expectedOutput.insert(htmlHead.size() - 3, " letter-spacing:13px; word-spacing:15px;"); expectedOutput += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>" + htmlTail; @@ -2071,7 +2071,7 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline() doc.setDefaultFont(fnt); QString expectedOutput = htmlHead; - expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;"); + expectedOutput.insert(htmlHead.size() - 3, " text-decoration: underline;"); expectedOutput += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Some text</p>" + htmlTail; @@ -2086,7 +2086,7 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline() cursor.mergeCharFormat(format); expectedOutput = htmlHead; - expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;"); + expectedOutput.insert(htmlHead.size() - 3, " text-decoration: underline;"); expectedOutput += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; " "margin-right:0px; -qt-block-indent:0; text-indent:0px;\">" @@ -2740,11 +2740,11 @@ void tst_QTextDocument::defaultTableStyle() brushes << sideProperty.value<QBrush>(); } auto errorDetails = qScopeGuard([&]{ - if (brushes.count() != borderBrushes.count()) { - qWarning("Different count: %lld vs %lld", brushes.count(), borderBrushes.count()); + if (brushes.size() != borderBrushes.size()) { + qWarning("Different count: %lld vs %lld", brushes.size(), borderBrushes.size()); return; } - for (int i = 0; i < brushes.count(); ++i) { + for (int i = 0; i < brushes.size(); ++i) { QString side; QDebug(&side) << QTextFormat::Property(QTextFormat::TableCellTopBorderBrush + i); QString actual; @@ -2868,13 +2868,13 @@ void tst_QTextDocument::blockCountChanged() doc->setPlainText("Foo"); QCOMPARE(doc->blockCount(), 1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); doc->setPlainText("Foo\nBar"); QCOMPARE(doc->blockCount(), 2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).value(0).toInt(), 2); spy.clear(); @@ -2882,16 +2882,16 @@ void tst_QTextDocument::blockCountChanged() cursor.movePosition(QTextCursor::End); cursor.insertText("Blahblah"); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); cursor.insertBlock(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).value(0).toInt(), 3); spy.clear(); doc->undo(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).value(0).toInt(), 2); } @@ -3070,12 +3070,12 @@ void tst_QTextDocument::characterAt() QString text("12345\n67890"); cursor.insertText(text); int length = doc.characterCount(); - QCOMPARE(length, text.length() + 1); + QCOMPARE(length, text.size() + 1); QCOMPARE(doc.characterAt(length-1), QChar(QChar::ParagraphSeparator)); QCOMPARE(doc.characterAt(-1), QChar()); QCOMPARE(doc.characterAt(length), QChar()); QCOMPARE(doc.characterAt(length + 1), QChar()); - for (int i = 0; i < text.length(); ++i) { + for (int i = 0; i < text.size(); ++i) { QChar c = text.at(i); if (c == QLatin1Char('\n')) c = QChar(QChar::ParagraphSeparator); @@ -3155,11 +3155,11 @@ void tst_QTextDocument::testUndoCommandAdded() QVERIFY(spy.isEmpty()); cursor.insertText("a"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); cursor.insertText("b"); // should be merged - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); cursor.insertText("c"); // should be merged - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(doc->toPlainText(), QString("abc")); doc->undo(); QCOMPARE(doc->toPlainText(), QString("")); @@ -3167,11 +3167,11 @@ void tst_QTextDocument::testUndoCommandAdded() doc->clear(); spy.clear(); cursor.insertText("aaa"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); cursor.insertText("aaaa\nbcd"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); cursor.beginEditBlock(); @@ -3181,11 +3181,11 @@ void tst_QTextDocument::testUndoCommandAdded() cursor.insertText("\nccc"); QVERIFY(spy.isEmpty()); cursor.endEditBlock(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); cursor.insertBlock(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); cursor.setPosition(5); @@ -3197,18 +3197,18 @@ void tst_QTextDocument::testUndoCommandAdded() QTextCharFormat cf; cf.setFontItalic(true); cursor.mergeCharFormat(cf); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); doc->undo(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); doc->undo(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); doc->redo(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); doc->redo(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTextDocument::testUndoBlocks() @@ -3788,7 +3788,7 @@ void tst_QTextDocument::mergeFontFamilies() QTextCursor cursor = QTextCursor(&td); cursor.setPosition(0); - cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor); + cursor.setPosition(QByteArray("Hello World").size(), QTextCursor::KeepAnchor); cursor.mergeCharFormat(newFormat); QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Jokerman';"))); @@ -3934,7 +3934,7 @@ void tst_QTextDocument::insertHtmlWithComments() QTextDocument doc; doc.setHtml(html); - QCOMPARE(doc.blockCount(), expectedBlocks.count()); + QCOMPARE(doc.blockCount(), expectedBlocks.size()); QStringList blockContent; auto currentBlock = doc.begin(); diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 52708e1b14..4cc4a253ee 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -1175,7 +1175,7 @@ void tst_QTextDocumentFragment::copySubTable() table->cellAt(row, col).firstCursorPosition().insertText(rowS + QString::number(col)); } - QCOMPARE(table->format().columnWidthConstraints().count(), table->columns()); + QCOMPARE(table->format().columnWidthConstraints().size(), table->columns()); // select 2x2 subtable cursor = table->cellAt(1, 1).firstCursorPosition(); @@ -2235,7 +2235,7 @@ void tst_QTextDocumentFragment::html_frameImport() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().margin(), ffmt.margin()); QCOMPARE(frame->frameFormat().border(), ffmt.border()); @@ -2263,7 +2263,7 @@ void tst_QTextDocumentFragment::html_frameImport2() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().topMargin(), ffmt.topMargin()); QCOMPARE(frame->frameFormat().bottomMargin(), ffmt.bottomMargin()); @@ -2278,7 +2278,7 @@ void tst_QTextDocumentFragment::html_dontAddMarginsAcrossTableCells() cursor.insertFragment(QTextDocumentFragment::fromHtml(QString::fromLatin1(html))); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); cursor = frame->firstCursorPosition(); QCOMPARE(cursor.blockFormat().leftMargin(), qreal(50.0)); @@ -2760,7 +2760,7 @@ void tst_QTextDocumentFragment::html_columnWidths() QTextTableFormat fmt = table->format(); const QList<QTextLength> columnWidths = fmt.columnWidthConstraints(); - QCOMPARE(columnWidths.count(), 2); + QCOMPARE(columnWidths.size(), 2); QCOMPARE(columnWidths.at(0).type(), QTextLength::VariableLength); QCOMPARE(columnWidths.at(1).type(), QTextLength::PercentageLength); QCOMPARE(columnWidths.at(1).rawValue(), qreal(1)); @@ -4168,7 +4168,7 @@ void tst_QTextDocumentFragment::html_entities() setHtml(html); QCOMPARE(doc->blockCount(), 1); QString txt = doc->begin().text(); - QCOMPARE(txt.length(), 1); + QCOMPARE(txt.size(), 1); QCOMPARE(txt.at(0).unicode(), code); } diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp index 9ef5842803..1b28274748 100644 --- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp +++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp @@ -187,7 +187,7 @@ void tst_QTextFormat::resolveFont() QTextCursor(&doc).insertText("Test", fmt); QList<QTextFormat> formats = doc.allFormats(); - QCOMPARE(formats.count(), 3); + QCOMPARE(formats.size(), 3); QCOMPARE(formats.at(2).type(), int(QTextFormat::CharFormat)); fmt = formats.at(2).toCharFormat(); @@ -312,8 +312,8 @@ void tst_QTextFormat::getSetTabs() public: Comparator(const QList<QTextOption::Tab> &tabs, const QList<QTextOption::Tab> &tabs2) { - QCOMPARE(tabs.count(), tabs2.count()); - for(int i=0; i < tabs.count(); i++) { + QCOMPARE(tabs.size(), tabs2.size()); + for(int i=0; i < tabs.size(); i++) { QTextOption::Tab t1 = tabs[i]; QTextOption::Tab t2 = tabs2[i]; QCOMPARE(t1.position, t2.position); @@ -364,7 +364,7 @@ void tst_QTextFormat::testTabsUsed() QCOMPARE(line.cursorToX(4), 100.); QTextOption option = layout->textOption(); - QCOMPARE(option.tabs().count(), tabs.count()); + QCOMPARE(option.tabs().size(), tabs.size()); } @@ -648,16 +648,16 @@ void tst_QTextFormat::clearCollection() charFormat2.setUnderlineStyle(QTextCharFormat::SingleUnderline); int formatIndex2 = collection.indexForFormat(charFormat2); QCOMPARE(formatIndex2, 1); - QCOMPARE(collection.formats.count(), 2); - QCOMPARE(collection.hashes.count(), 2); + QCOMPARE(collection.formats.size(), 2); + QCOMPARE(collection.hashes.size(), 2); QCOMPARE(collection.defaultFont(), f); collection.clear(); - QCOMPARE(collection.formats.count(), 0); - QCOMPARE(collection.hashes.count(), 0); + QCOMPARE(collection.formats.size(), 0); + QCOMPARE(collection.hashes.size(), 0); QCOMPARE(collection.indexForFormat(charFormat2), 0); - QCOMPARE(collection.formats.count(), 1); - QCOMPARE(collection.hashes.count(), 1); + QCOMPARE(collection.formats.size(), 1); + QCOMPARE(collection.hashes.size(), 1); QCOMPARE(collection.defaultFont(), f); // kept, QTextDocument::clear or setPlainText should not reset the font set by setDefaultFont } diff --git a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp index 30185e83b9..3ae6046bdb 100644 --- a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp @@ -79,7 +79,7 @@ QString tst_QTextOdfWriter::getContentFromXml() if (index > 0) { index = stringContent.indexOf('>', index); if (index > 0) - ret = stringContent.mid(index+1, stringContent.length() - index - 10); + ret = stringContent.mid(index+1, stringContent.size() - index - 10); } return ret; } @@ -279,7 +279,7 @@ file.open(QIODevice::WriteOnly); file.write(buffer->data()); file.close(); */ - QVERIFY(buffer->data().length() > 80); + QVERIFY(buffer->data().size() > 80); QCOMPARE(buffer->data()[0], 'P'); // its a zip :) QCOMPARE(buffer->data()[1], 'K'); QString mimetype(buffer->data().mid(38, 39)); diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp index 71afd31574..cac84de7e2 100644 --- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp @@ -971,7 +971,7 @@ void tst_QTextPieceTable::checkFrames1() QVERIFY(root); QVERIFY(!root->parentFrame()); - QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().size(), 1); QVERIFY(frame->format() == ffmt); QCOMPARE(frame->firstPosition(), 2); QCOMPARE(frame->lastPosition(), 4); @@ -979,10 +979,10 @@ void tst_QTextPieceTable::checkFrames1() QPointer<QTextFrame> frame2 = table->insertFrame(2, 3, ffmt); - QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().size(), 1); QCOMPARE(root->childFrames().at(0), frame.data()); - QCOMPARE(frame->childFrames().count(), 1); - QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame->childFrames().size(), 1); + QCOMPARE(frame2->childFrames().size(), 0); QCOMPARE(frame2->parentFrame(), frame.data()); QCOMPARE(frame2->firstPosition(), 3); QCOMPARE(frame2->lastPosition(), 4); @@ -993,10 +993,10 @@ void tst_QTextPieceTable::checkFrames1() table->removeFrame(frame); - QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().size(), 1); QCOMPARE(root->childFrames().at(0), frame2.data()); QVERIFY(!frame); - QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame2->childFrames().size(), 0); QCOMPARE(frame2->parentFrame(), root); QCOMPARE(frame2->firstPosition(), 2); QCOMPARE(frame2->lastPosition(), 3); @@ -1005,11 +1005,11 @@ void tst_QTextPieceTable::checkFrames1() frame = table->frameAt(2); - QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().size(), 1); QCOMPARE(root->childFrames().at(0), frame.data()); - QCOMPARE(frame->childFrames().count(), 1); + QCOMPARE(frame->childFrames().size(), 1); QCOMPARE(frame->childFrames().at(0), frame2.data()); - QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame2->childFrames().size(), 0); QCOMPARE(frame2->parentFrame(), frame.data()); QCOMPARE(frame2->firstPosition(), 3); QCOMPARE(frame2->lastPosition(), 4); @@ -1019,9 +1019,9 @@ void tst_QTextPieceTable::checkFrames1() table->undo(); - QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().size(), 1); QCOMPARE(root->childFrames().at(0), frame.data()); - QCOMPARE(frame->childFrames().count(), 0); + QCOMPARE(frame->childFrames().size(), 0); QVERIFY(!frame2); QCOMPARE(frame->firstPosition(), 2); diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index bfead23d4d..ae5502852c 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -121,7 +121,7 @@ void tst_QTextTable::variousTableModifications() QTextTableFormat tableFmt; QTextTable *tab = cursor.insertTable(2, 2, tableFmt); - QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(doc->toPlainText().size(), 5); QCOMPARE(tab, cursor.currentTable()); QCOMPARE(tab->columns(), 2); QCOMPARE(tab->rows(), 2); @@ -176,14 +176,14 @@ void tst_QTextTable::variousTableModifications() cursor.movePosition(QTextCursor::NextBlock); QCOMPARE(cursor.position(), 1); cursor.deleteChar(); - QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(doc->toPlainText().size(), 5); cursor.movePosition(QTextCursor::NextBlock); QCOMPARE(cursor.position(), 2); cursor.deleteChar(); - QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(doc->toPlainText().size(), 5); cursor.deletePreviousChar(); QCOMPARE(cursor.position(), 2); - QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(doc->toPlainText().size(), 5); QTextTable *table = cursor.currentTable(); QCOMPARE(table->rows(), 2); @@ -192,16 +192,16 @@ void tst_QTextTable::variousTableModifications() table->insertRows(2, 1); QCOMPARE(table->rows(), 3); QCOMPARE(table->columns(), 2); - QCOMPARE(doc->toPlainText().length(), 7); + QCOMPARE(doc->toPlainText().size(), 7); table->insertColumns(2, 2); QCOMPARE(table->rows(), 3); QCOMPARE(table->columns(), 4); - QCOMPARE(doc->toPlainText().length(), 13); + QCOMPARE(doc->toPlainText().size(), 13); table->resize(4, 5); QCOMPARE(table->rows(), 4); QCOMPARE(table->columns(), 5); - QCOMPARE(doc->toPlainText().length(), 21); + QCOMPARE(doc->toPlainText().size(), 21); } void tst_QTextTable::tableShrinking() @@ -209,7 +209,7 @@ void tst_QTextTable::tableShrinking() QTextTableFormat tableFmt; cursor.insertTable(3, 4, tableFmt); - QCOMPARE(doc->toPlainText().length(), 13); + QCOMPARE(doc->toPlainText().size(), 13); QTextTable *table = cursor.currentTable(); QCOMPARE(table->rows(), 3); @@ -218,16 +218,16 @@ void tst_QTextTable::tableShrinking() table->removeRows(1, 1); QCOMPARE(table->rows(), 2); QCOMPARE(table->columns(), 4); - QCOMPARE(doc->toPlainText().length(), 9); + QCOMPARE(doc->toPlainText().size(), 9); table->removeColumns(1, 2); QCOMPARE(table->rows(), 2); QCOMPARE(table->columns(), 2); - QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(doc->toPlainText().size(), 5); table->resize(1, 1); QCOMPARE(table->rows(), 1); QCOMPARE(table->columns(), 1); - QCOMPARE(doc->toPlainText().length(), 2); + QCOMPARE(doc->toPlainText().size(), 2); } void tst_QTextTable::spans() @@ -252,7 +252,7 @@ void tst_QTextTable::variousModifications2() QTextTableFormat tableFmt; cursor.insertTable(2, 5, tableFmt); - QCOMPARE(doc->toPlainText().length(), 11); + QCOMPARE(doc->toPlainText().size(), 11); QTextTable *table = cursor.currentTable(); QCOMPARE(cursor.position(), 1); QCOMPARE(table->rows(), 2); @@ -1148,8 +1148,8 @@ void tst_QTextTable::QTBUG31330_renderBackground() doc.print(&paintDevice); QVERIFY(paintDevice.pages >= 2); - QCOMPARE(engine.rects.count(), paintDevice.pages); - for (int i = 0; i < engine.rects.count(); ++i) { + QCOMPARE(engine.rects.size(), paintDevice.pages); + for (int i = 0; i < engine.rects.size(); ++i) { QRectF rect = engine.rects[i]; QVERIFY(rect.top() > 0); QVERIFY(rect.bottom() < 1000); diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp index 128f0b3200..3e2dc39983 100644 --- a/tests/auto/gui/text/qzip/tst_qzip.cpp +++ b/tests/auto/gui/text/qzip/tst_qzip.cpp @@ -23,7 +23,7 @@ void tst_QZip::basicUnpack() { QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly); QList<QZipReader::FileInfo> files = zip.fileInfoList(); - QCOMPARE(files.count(), 2); + QCOMPARE(files.size(), 2); QZipReader::FileInfo fi = files.at(0); QVERIFY(fi.isValid()); @@ -59,7 +59,7 @@ void tst_QZip::symlinks() { QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly); QList<QZipReader::FileInfo> files = zip.fileInfoList(); - QCOMPARE(files.count(), 2); + QCOMPARE(files.size(), 2); QZipReader::FileInfo fi = files.at(0); QVERIFY(fi.isValid()); @@ -82,7 +82,7 @@ void tst_QZip::readTest() { QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file. QList<QZipReader::FileInfo> files = zip.fileInfoList(); - QCOMPARE(files.count(), 0); + QCOMPARE(files.size(), 0); QByteArray b = zip.fileData("foobar"); QCOMPARE(b.size(), 0); } @@ -101,7 +101,7 @@ void tst_QZip::createArchive() QBuffer buffer2(&zipFile); QZipReader zip2(&buffer2); QList<QZipReader::FileInfo> files = zip2.fileInfoList(); - QCOMPARE(files.count(), 1); + QCOMPARE(files.size(), 1); QZipReader::FileInfo file = files.at(0); QCOMPARE(file.filePath, QString("My Filename")); QCOMPARE(uint(file.isDir), (uint) 0); diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp index 225ac14c7f..a29de07183 100644 --- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp +++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp @@ -311,74 +311,74 @@ void tst_QDoubleValidator::notifySignals() QCOMPARE(dv.decimals(), 10); dv.setTop(0.8); - QCOMPARE(topSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); + QCOMPARE(topSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); QCOMPARE(dv.top(), 0.8); dv.setBottom(0.2); - QCOMPARE(bottomSpy.count(), 1); - QCOMPARE(changedSpy.count(), 2); + QCOMPARE(bottomSpy.size(), 1); + QCOMPARE(changedSpy.size(), 2); QCOMPARE(dv.bottom(), 0.2); dv.setRange(0.2, 0.7); - QCOMPARE(topSpy.count(), 2); - QCOMPARE(bottomSpy.count(), 1); - QCOMPARE(decSpy.count(), 0); - QCOMPARE(changedSpy.count(), 3); + QCOMPARE(topSpy.size(), 2); + QCOMPARE(bottomSpy.size(), 1); + QCOMPARE(decSpy.size(), 0); + QCOMPARE(changedSpy.size(), 3); QCOMPARE(dv.bottom(), 0.2); QCOMPARE(dv.top(), 0.7); QCOMPARE(dv.decimals(), 10); dv.setRange(0.3, 0.7); - QCOMPARE(topSpy.count(), 2); - QCOMPARE(bottomSpy.count(), 2); - QCOMPARE(changedSpy.count(), 4); + QCOMPARE(topSpy.size(), 2); + QCOMPARE(bottomSpy.size(), 2); + QCOMPARE(changedSpy.size(), 4); QCOMPARE(dv.bottom(), 0.3); QCOMPARE(dv.top(), 0.7); QCOMPARE(dv.decimals(), 10); dv.setRange(0.4, 0.6); - QCOMPARE(topSpy.count(), 3); - QCOMPARE(bottomSpy.count(), 3); - QCOMPARE(changedSpy.count(), 5); + QCOMPARE(topSpy.size(), 3); + QCOMPARE(bottomSpy.size(), 3); + QCOMPARE(changedSpy.size(), 5); QCOMPARE(dv.bottom(), 0.4); QCOMPARE(dv.top(), 0.6); QCOMPARE(dv.decimals(), 10); dv.setDecimals(5); - QCOMPARE(decSpy.count(), 1); - QCOMPARE(changedSpy.count(), 6); + QCOMPARE(decSpy.size(), 1); + QCOMPARE(changedSpy.size(), 6); QCOMPARE(dv.decimals(), 5); dv.setRange(0.4, 0.6, 100); - QCOMPARE(topSpy.count(), 3); - QCOMPARE(bottomSpy.count(), 3); - QCOMPARE(decSpy.count(), 2); - QCOMPARE(changedSpy.count(), 7); + QCOMPARE(topSpy.size(), 3); + QCOMPARE(bottomSpy.size(), 3); + QCOMPARE(decSpy.size(), 2); + QCOMPARE(changedSpy.size(), 7); QCOMPARE(dv.bottom(), 0.4); QCOMPARE(dv.top(), 0.6); QCOMPARE(dv.decimals(), 100); dv.setNotation(QDoubleValidator::StandardNotation); - QCOMPARE(notSpy.count(), 1); - QCOMPARE(changedSpy.count(), 8); + QCOMPARE(notSpy.size(), 1); + QCOMPARE(changedSpy.size(), 8); QCOMPARE(dv.notation(), QDoubleValidator::StandardNotation); dv.setRange(dv.bottom(), dv.top(), dv.decimals()); - QCOMPARE(topSpy.count(), 3); - QCOMPARE(bottomSpy.count(), 3); - QCOMPARE(decSpy.count(), 2); - QCOMPARE(changedSpy.count(), 8); + QCOMPARE(topSpy.size(), 3); + QCOMPARE(bottomSpy.size(), 3); + QCOMPARE(decSpy.size(), 2); + QCOMPARE(changedSpy.size(), 8); dv.setNotation(dv.notation()); - QCOMPARE(notSpy.count(), 1); - QCOMPARE(changedSpy.count(), 8); + QCOMPARE(notSpy.size(), 1); + QCOMPARE(changedSpy.size(), 8); dv.setLocale(QLocale("C")); - QCOMPARE(changedSpy.count(), 8); + QCOMPARE(changedSpy.size(), 8); dv.setLocale(QLocale("en")); - QCOMPARE(changedSpy.count(), 9); + QCOMPARE(changedSpy.size(), 9); } void tst_QDoubleValidator::fixup() diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp index 6e380bdcaa..ec4e3930ec 100644 --- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp @@ -211,45 +211,45 @@ void tst_QIntValidator::notifySignals() QSignalSpy changedSpy(&iv, SIGNAL(changed())); iv.setTop(9); - QCOMPARE(topSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); + QCOMPARE(topSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); QCOMPARE(iv.top(), 9); iv.setBottom(1); - QCOMPARE(bottomSpy.count(), 1); - QCOMPARE(changedSpy.count(), 2); + QCOMPARE(bottomSpy.size(), 1); + QCOMPARE(changedSpy.size(), 2); QCOMPARE(iv.bottom(), 1); iv.setRange(1, 8); - QCOMPARE(topSpy.count(), 2); - QCOMPARE(bottomSpy.count(), 1); - QCOMPARE(changedSpy.count(), 3); + QCOMPARE(topSpy.size(), 2); + QCOMPARE(bottomSpy.size(), 1); + QCOMPARE(changedSpy.size(), 3); QCOMPARE(iv.top(), 8); QCOMPARE(iv.bottom(), 1); iv.setRange(2, 8); - QCOMPARE(topSpy.count(), 2); - QCOMPARE(bottomSpy.count(), 2); - QCOMPARE(changedSpy.count(), 4); + QCOMPARE(topSpy.size(), 2); + QCOMPARE(bottomSpy.size(), 2); + QCOMPARE(changedSpy.size(), 4); QCOMPARE(iv.top(), 8); QCOMPARE(iv.bottom(), 2); iv.setRange(3, 7); - QCOMPARE(topSpy.count(), 3); - QCOMPARE(bottomSpy.count(), 3); - QCOMPARE(changedSpy.count(), 5); + QCOMPARE(topSpy.size(), 3); + QCOMPARE(bottomSpy.size(), 3); + QCOMPARE(changedSpy.size(), 5); QCOMPARE(iv.top(), 7); QCOMPARE(iv.bottom(), 3); iv.setRange(3, 7); - QCOMPARE(topSpy.count(), 3); - QCOMPARE(bottomSpy.count(), 3); - QCOMPARE(changedSpy.count(), 5); + QCOMPARE(topSpy.size(), 3); + QCOMPARE(bottomSpy.size(), 3); + QCOMPARE(changedSpy.size(), 5); iv.setLocale(QLocale("C")); - QCOMPARE(changedSpy.count(), 5); + QCOMPARE(changedSpy.size(), 5); iv.setLocale(QLocale("en")); - QCOMPARE(changedSpy.count(), 6); + QCOMPARE(changedSpy.size(), 6); } void tst_QIntValidator::fixup() diff --git a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp index d78ee31864..c2ddafa2c6 100644 --- a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp +++ b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp @@ -73,12 +73,12 @@ void tst_QRegularExpressionValidator::validate() QTEST(result, "state"); if (result == QValidator::Invalid) - QCOMPARE(pos, value.length()); + QCOMPARE(pos, value.size()); else QCOMPARE(pos, -1); // ensure pos is not modified if validate returned Acceptable or Intermediate - QCOMPARE(spy.count(), signalCount); - QCOMPARE(changedSpy.count(), signalCount); + QCOMPARE(spy.size(), signalCount); + QCOMPARE(changedSpy.size(), signalCount); } QTEST_GUILESS_MAIN(tst_QRegularExpressionValidator) diff --git a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp index bcecfc26b9..f554e94a98 100644 --- a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp @@ -65,7 +65,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text, QUndoCommand *parent) : QUndoCommand(parent) { - QVERIFY(str->length() >= idx); + QVERIFY(str->size() >= idx); setText("insert"); @@ -76,22 +76,22 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text, void InsertCommand::redo() { - QVERIFY(m_str->length() >= m_idx); + QVERIFY(m_str->size() >= m_idx); m_str->insert(m_idx, m_text); } void InsertCommand::undo() { - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); + QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text); - m_str->remove(m_idx, m_text.length()); + m_str->remove(m_idx, m_text.size()); } RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent) : QUndoCommand(parent) { - QVERIFY(str->length() >= idx + len); + QVERIFY(str->size() >= idx + len); setText("remove"); @@ -102,14 +102,14 @@ RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *paren void RemoveCommand::redo() { - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); + QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text); - m_str->remove(m_idx, m_text.length()); + m_str->remove(m_idx, m_text.size()); } void RemoveCommand::undo() { - QVERIFY(m_str->length() >= m_idx); + QVERIFY(m_str->size() >= m_idx); m_str->insert(m_idx, m_text); } @@ -131,9 +131,9 @@ void AppendCommand::redo() void AppendCommand::undo() { - QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text); + QCOMPARE(m_str->mid(m_str->size() - m_text.size()), m_text); - m_str->truncate(m_str->length() - m_text.length()); + m_str->truncate(m_str->size() - m_text.size()); } int AppendCommand::id() const diff --git a/tests/auto/gui/util/qundostack/tst_qundostack.cpp b/tests/auto/gui/util/qundostack/tst_qundostack.cpp index bdb664ad7e..b47a4ee1a9 100644 --- a/tests/auto/gui/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/gui/util/qundostack/tst_qundostack.cpp @@ -97,7 +97,7 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text, QUndoCommand *parent) : QUndoCommand(parent) { - QVERIFY(str->length() >= idx); + QVERIFY(str->size() >= idx); setText("insert"); @@ -108,22 +108,22 @@ InsertCommand::InsertCommand(QString *str, int idx, const QString &text, void InsertCommand::redo() { - QVERIFY(m_str->length() >= m_idx); + QVERIFY(m_str->size() >= m_idx); m_str->insert(m_idx, m_text); } void InsertCommand::undo() { - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); + QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text); - m_str->remove(m_idx, m_text.length()); + m_str->remove(m_idx, m_text.size()); } RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent) : QUndoCommand(parent) { - QVERIFY(str->length() >= idx + len); + QVERIFY(str->size() >= idx + len); setText("remove"); @@ -134,14 +134,14 @@ RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *paren void RemoveCommand::redo() { - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); + QCOMPARE(m_str->mid(m_idx, m_text.size()), m_text); - m_str->remove(m_idx, m_text.length()); + m_str->remove(m_idx, m_text.size()); } void RemoveCommand::undo() { - QVERIFY(m_str->length() >= m_idx); + QVERIFY(m_str->size() >= m_idx); m_str->insert(m_idx, m_text); } @@ -172,9 +172,9 @@ void AppendCommand::redo() void AppendCommand::undo() { - QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text); + QCOMPARE(m_str->mid(m_str->size() - m_text.size()), m_text); - m_str->truncate(m_str->length() - m_text.length()); + m_str->truncate(m_str->size() - m_text.size()); } int AppendCommand::id() const @@ -324,44 +324,44 @@ static void checkState(QSignalSpy &redoTextChangedSpy, QCOMPARE(stack.canRedo(), _canRedo); QCOMPARE(stack.redoText(), QString(_redoText)); if (_indexChanged) { - QCOMPARE(indexChangedSpy.count(), 1); + QCOMPARE(indexChangedSpy.size(), 1); QCOMPARE(indexChangedSpy.at(0).at(0).toInt(), _index); indexChangedSpy.clear(); } else { - QCOMPARE(indexChangedSpy.count(), 0); + QCOMPARE(indexChangedSpy.size(), 0); } if (_cleanChanged) { - QCOMPARE(cleanChangedSpy.count(), 1); + QCOMPARE(cleanChangedSpy.size(), 1); QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean); cleanChangedSpy.clear(); } else { - QCOMPARE(cleanChangedSpy.count(), 0); + QCOMPARE(cleanChangedSpy.size(), 0); } if (_undoChanged) { - QCOMPARE(canUndoChangedSpy.count(), 1); + QCOMPARE(canUndoChangedSpy.size(), 1); QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo); QCOMPARE(undoAction->isEnabled(), _canUndo); - QCOMPARE(undoTextChangedSpy.count(), 1); + QCOMPARE(undoTextChangedSpy.size(), 1); QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText)); QCOMPARE(undoAction->text(), glue("foo", _undoText)); canUndoChangedSpy.clear(); undoTextChangedSpy.clear(); } else { - QCOMPARE(canUndoChangedSpy.count(), 0); - QCOMPARE(undoTextChangedSpy.count(), 0); + QCOMPARE(canUndoChangedSpy.size(), 0); + QCOMPARE(undoTextChangedSpy.size(), 0); } if (_redoChanged) { - QCOMPARE(canRedoChangedSpy.count(), 1); + QCOMPARE(canRedoChangedSpy.size(), 1); QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo); QCOMPARE(redoAction->isEnabled(), _canRedo); - QCOMPARE(redoTextChangedSpy.count(), 1); + QCOMPARE(redoTextChangedSpy.size(), 1); QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText)); QCOMPARE(redoAction->text(), glue("bar", _redoText)); canRedoChangedSpy.clear(); redoTextChangedSpy.clear(); } else { - QCOMPARE(canRedoChangedSpy.count(), 0); - QCOMPARE(redoTextChangedSpy.count(), 0); + QCOMPARE(canRedoChangedSpy.size(), 0); + QCOMPARE(redoTextChangedSpy.size(), 0); } } diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 159fa67a34..9c1a63bae1 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -292,7 +292,7 @@ void tst_Http2::singleRequest() #if QT_CONFIG(ssl) if (connectionType == H2Type::h2Alpn || connectionType == H2Type::h2Direct) - QCOMPARE(encSpy.count(), 1); + QCOMPARE(encSpy.size(), 1); #endif // QT_CONFIG(ssl) } @@ -780,7 +780,7 @@ void tst_Http2::maxFrameSize() // Normally, with a 16kb limit, our server would split such // a response into 3 'DATA' frames (16kb + 16kb + 0|END_STREAM). - QCOMPARE(frameCounter.count(), 1); + QCOMPARE(frameCounter.size(), 1); QVERIFY(nRequests == 0); QVERIFY(prefaceOK); diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index d40411ba3d..28bbf5459a 100644 --- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -265,7 +265,7 @@ void tst_QAbstractNetworkCache::runTest() // prime the cache QNetworkReply *reply = manager.get(request); QSignalSpy downloaded1(reply, SIGNAL(finished())); - QTRY_COMPARE(downloaded1.count(), 1); + QTRY_COMPARE(downloaded1.size(), 1); QCOMPARE(diskCache->gotData, false); QByteArray goodData = reply->readAll(); @@ -274,7 +274,7 @@ void tst_QAbstractNetworkCache::runTest() // should be in the cache now QNetworkReply *reply2 = manager.get(request); QSignalSpy downloaded2(reply2, SIGNAL(finished())); - QTRY_COMPARE(downloaded2.count(), 1); + QTRY_COMPARE(downloaded2.size(), 1); QByteArray secondData = reply2->readAll(); if (!fetchFromCache && cacheLoadControl == QNetworkRequest::AlwaysCache) { @@ -363,7 +363,7 @@ void tst_QAbstractNetworkCache::deleteCache() QNetworkReply *reply = manager.get(request); QSignalSpy downloaded1(reply, SIGNAL(finished())); manager.setCache(0); - QTRY_COMPARE(downloaded1.count(), 1); + QTRY_COMPARE(downloaded1.size(), 1); } diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index b1f3966285..6833eb5bc9 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -666,7 +666,7 @@ void tst_QHttpNetworkConnection::getMultiple_data() static bool allRepliesFinished(const QList<QHttpNetworkReply*> *_replies) { const QList<QHttpNetworkReply*> &replies = *_replies; - for (int i = 0; i < replies.length(); i++) + for (int i = 0; i < replies.size(); i++) if (!replies.at(i)->isFinished()) return false; return true; @@ -735,7 +735,7 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( QTRY_VERIFY_WITH_TIMEOUT(allRepliesFinished(&replies), 60000); int pipelinedCount = 0; - for (int i = 0; i < replies.length(); i++) { + for (int i = 0; i < replies.size(); i++) { QVERIFY (!(replies.at(i)->request().isPipeliningAllowed() == false && replies.at(i)->isPipeliningUsed())); diff --git a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp index e36acc81da..0780ae1f0e 100644 --- a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp +++ b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp @@ -77,7 +77,7 @@ void tst_QHttpNetworkReply::parseHeader() QHttpNetworkReply reply; reply.parseHeader(headers); - for (int i = 0; i < fields.count(); ++i) { + for (int i = 0; i < fields.size(); ++i) { //qDebug() << "field" << fields.at(i) << "value" << reply.headerField(fields.at(i)) << "expected" << values.at(i); QString field = reply.headerField(fields.at(i).toLatin1()); QCOMPARE(field, values.at(i)); diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp index d6709a614c..18fd0f01ab 100644 --- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp @@ -553,11 +553,11 @@ void tst_QNetworkCookie::parseSingleCookie() QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toUtf8()); //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); - QCOMPARE(result.count(), 1); + QCOMPARE(result.size(), 1); QCOMPARE(result.at(0), expectedCookie); result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); - QCOMPARE(result.count(), 1); + QCOMPARE(result.size(), 1); // Drop any millisecond information, if there's any QDateTime dt = expectedCookie.expirationDate(); diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index ddce612684..301bb633b8 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -546,9 +546,9 @@ void tst_QNetworkCookieJar::rfc6265() QList<QNetworkCookie> cookiesToSend = jar.cookiesForUrl(sentUrl); //compare cookies only using name/value, as the metadata isn't sent over the network - QCOMPARE(cookiesToSend.count(), sent.count()); + QCOMPARE(cookiesToSend.size(), sent.size()); bool ok = true; - for (int i = 0; i < cookiesToSend.count(); i++) { + for (int i = 0; i < cookiesToSend.size(); i++) { if (cookiesToSend.at(i).name() != sent.at(i).name()) { ok = false; break; diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index fec66ebbd0..64a569e9fa 100644 --- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -278,17 +278,17 @@ void tst_QNetworkDiskCache::clear() QVERIFY(cache.cacheSize() > qint64(0)); QString cacheDirectory = cache.cacheDirectory(); - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3); cache.clear(); - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 2); // don't delete files that it didn't create QTemporaryFile file(cacheDirectory + "/XXXXXX"); if (file.open()) { file.fileName(); // make sure it exists with a name - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3); cache.clear(); - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3); } } @@ -355,9 +355,9 @@ void tst_QNetworkDiskCache::remove() QUrl url(EXAMPLE_URL); cache.setupWithOne(tempDir.path(), url); QString cacheDirectory = cache.cacheDirectory(); - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 3); cache.remove(url); - QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2); + QCOMPARE(countFiles(cacheDirectory).size(), NUM_SUBDIRECTORIES + 2); } void tst_QNetworkDiskCache::accessAfterRemove() // QTBUG-17400 @@ -477,7 +477,7 @@ void tst_QNetworkDiskCache::fileMetaData() QString cacheDirectory = cache.cacheDirectory(); QStringList list = countFiles(cacheDirectory); - QCOMPARE(list.count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(list.size(), NUM_SUBDIRECTORIES + 3); foreach(QString fileName, list) { QFileInfo info(fileName); if (info.isFile()) { @@ -531,7 +531,7 @@ void tst_QNetworkDiskCache::expire() } } std::sort(cacheList.begin(), cacheList.end()); - for (int i = 0; i < cacheList.count(); ++i) { + for (int i = 0; i < cacheList.size(); ++i) { QString fileName = cacheList[i]; QCOMPARE(fileName, QLatin1String("http://localhost:4/") + QString::number(i + 6)); } @@ -570,7 +570,7 @@ void tst_QNetworkDiskCache::oldCacheVersionFile() QVERIFY(!QFile::exists(name)); } else { QStringList files = countFiles(cache.cacheDirectory()); - QCOMPARE(files.count(), NUM_SUBDIRECTORIES + 3); + QCOMPARE(files.size(), NUM_SUBDIRECTORIES + 3); // find the file QString cacheFile; foreach (QString file, files) { @@ -736,7 +736,7 @@ public: if (d) { QByteArray x = d->readAll(); if (x != longString && x != longString2) { - qDebug() << x.length() << QString(x); + qDebug() << x.size() << QString(x); gotMetaData = cache.metaData(url); qDebug() << (gotMetaData.url().toString()) << gotMetaData.lastModified() diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index e653ebf698..ea8e31c5e6 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -733,7 +733,7 @@ public slots: || receivedData.startsWith("CUSTOM_WITH_PAYLOAD"); if (hasContent && contentLength == 0) parseContentLength(); - contentRead = receivedData.length() - endOfHeader; + contentRead = receivedData.size() - endOfHeader; if (hasContent && contentRead < contentLength) return; @@ -1460,11 +1460,11 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op, while (!reply->isFinished()) { QTimer::singleShot(20000, loop, SLOT(quit())); code = loop->exec(); - if (count == spy.count() && !reply->isFinished()) { + if (count == spy.size() && !reply->isFinished()) { code = Timeout; break; } - count = spy.count(); + count = spy.size(); } delete loop; loop = 0; @@ -1530,11 +1530,11 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { QTimer::singleShot(5000, loop, SLOT(quit())); - if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + if (loop->exec() == Timeout && count == spy.size() && !reply->isFinished()) { returnCode = Timeout; break; } - count = spy.count(); + count = spy.size(); } delete loop; loop = 0; @@ -1995,7 +1995,7 @@ void tst_QNetworkReply::headFromHttp_data() QString httpServer = QtNetworkSettings::httpServerName(); //testing proxies, mainly for the 407 response from http proxy - for (int i = 0; i < proxies.count(); ++i) { + for (int i = 0; i < proxies.size(); ++i) { QTest::newRow("rfc" + proxies.at(i).tag) << rfcsize << QUrl("http://" + httpServer + "/qtest/rfc3252.txt") @@ -2277,9 +2277,9 @@ void tst_QNetworkReply::putToFtp() QSignalSpy spy(r, SIGNAL(downloadProgress(qint64,qint64))); while (!r->isFinished()) { QTestEventLoop::instance().enterLoop(10); - if (count == spy.count() && !r->isFinished()) + if (count == spy.size() && !r->isFinished()) break; - count = spy.count(); + count = spy.size(); } QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); @@ -3589,7 +3589,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() QCOMPARE(reader1.data, expectedData); QCOMPARE(reader2.data, expectedData); - QCOMPARE(authspy.count(), (expectedAuth ? 1 : 0)); + QCOMPARE(authspy.size(), (expectedAuth ? 1 : 0)); expectedAuth = qMax(0, expectedAuth - 1); } @@ -3610,7 +3610,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reader.data, expectedData); - QCOMPARE(authspy.count(), (expectedAuth ? 1 : 0)); + QCOMPARE(authspy.size(), (expectedAuth ? 1 : 0)); expectedAuth = qMax(0, expectedAuth - 1); } @@ -3627,7 +3627,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() // bad credentials in a synchronous request should just fail QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError); } else { - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); // we cannot use a data reader here, since that connects to the readyRead signal, // just use readAll() @@ -3653,7 +3653,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() // bad credentials in a synchronous request should just fail QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError); } else { - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); // we cannot use a data reader here, since that connects to the readyRead signal, // just use readAll() @@ -3679,7 +3679,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous() QNetworkReplyPtr replySync(manager.get(request)); QVERIFY(replySync->isFinished()); // synchronous QCOMPARE(replySync->error(), QNetworkReply::AuthenticationRequiredError); - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 401); } @@ -3720,7 +3720,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() QCOMPARE(reader1.data, referenceData); QCOMPARE(reader2.data, referenceData); - QCOMPARE(authspy.count(), 1); + QCOMPARE(authspy.size(), 1); } reference.seek(0); @@ -3743,7 +3743,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reader.data, reference.readAll()); - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); } // now check with synchronous calls: @@ -3756,7 +3756,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() QSignalSpy authspy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); QNetworkReplyPtr replySync(manager.get(request)); QVERIFY(replySync->isFinished()); // synchronous - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); // we cannot use a data reader here, since that connects to the readyRead signal, // just use readAll() @@ -3784,7 +3784,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuthSynchronous() manager.setProxy(QNetworkProxy()); // reset QVERIFY(replySync->isFinished()); // synchronous QCOMPARE(replySync->error(), QNetworkReply::ProxyAuthenticationRequiredError); - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 407); } @@ -3816,7 +3816,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reader.data, reference.readAll()); - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); } // set an invalid proxy just to make sure that we can't load @@ -3843,7 +3843,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() QEXPECT_FAIL("", "QTcpSocket doesn't return enough information yet", Continue); QCOMPARE(int(reply->error()), int(QNetworkReply::ProxyConnectionRefusedError)); - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); } } #endif // QT_CONFIG(networkproxy) @@ -3871,7 +3871,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslErrors() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reader.data, reference.readAll()); - QCOMPARE(sslspy.count(), 1); + QCOMPARE(sslspy.size(), 1); QVERIFY(!storedSslConfiguration.isNull()); QVERIFY(!reply->sslConfiguration().isNull()); @@ -3899,7 +3899,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reader.data, reference.readAll()); - QCOMPARE(sslspy.count(), 1); + QCOMPARE(sslspy.size(), 1); QVERIFY(!storedSslConfiguration.isNull()); QVERIFY(!reply->sslConfiguration().isNull()); @@ -3922,7 +3922,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError() QCOMPARE(waitForFinish(reply), int(Failure)); QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError); - QCOMPARE(sslspy.count(), 0); + QCOMPARE(sslspy.size(), 0); } #endif @@ -3980,7 +3980,7 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer() QCOMPARE(waitForFinish(reply), int(Failure)); QCOMPARE(reply->url(), request.url()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(reply->error() != QNetworkReply::NoError); } @@ -4498,16 +4498,16 @@ void tst_QNetworkReply::ioGetWithManyProxies() // now verify that the proxies worked: QFETCH(QNetworkProxy, proxyUsed); if (proxyUsed.type() == QNetworkProxy::NoProxy) { - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); } else { if (QByteArray(QTest::currentDataTag()).startsWith("ftp-")) return; // No authentication with current FTP or with FTP proxies - QCOMPARE(authspy.count(), 1); + QCOMPARE(authspy.size(), 1); QCOMPARE(qvariant_cast<QNetworkProxy>(authspy.at(0).at(0)), proxyUsed); } } else { // request failed - QCOMPARE(authspy.count(), 0); + QCOMPARE(authspy.size(), 0); } } #endif // QT_CONFIG(networkproxy) @@ -4813,7 +4813,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket_data() QTest::addColumn<int>("authenticationRequiredCount"); QTest::addColumn<int>("proxyAuthenticationRequiredCount"); - for (int i = 0; i < proxies.count(); ++i) + for (int i = 0; i < proxies.size(); ++i) for (int auth = 0; auth < 2; ++auth) { QUrl url; if (auth) @@ -4891,8 +4891,8 @@ void tst_QNetworkReply::ioPostToHttpFromSocket() QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex()); - QTEST(int(authenticationRequiredSpy.count()), "authenticationRequiredCount"); - QTEST(int(proxyAuthenticationRequiredSpy.count()), "proxyAuthenticationRequiredCount"); + QTEST(int(authenticationRequiredSpy.size()), "authenticationRequiredCount"); + QTEST(int(proxyAuthenticationRequiredSpy.size()), "proxyAuthenticationRequiredCount"); } void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous_data() @@ -5391,7 +5391,7 @@ void tst_QNetworkReply::emitAllUploadProgressSignals() QVERIFY(!QTestEventLoop::instance().timeout()); incomingSocket->close(); - signalCount.append(spy.count()); + signalCount.append(spy.size()); reply->deleteLater(); } server.close(); @@ -5437,7 +5437,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress() QVERIFY(!QTestEventLoop::instance().timeout()); // final check: only 1 uploadProgress has been emitted - QCOMPARE(spy.length(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.last(); QVERIFY(!args.isEmpty()); QCOMPARE(args.at(0).toLongLong(), buffer.size()); @@ -5608,7 +5608,7 @@ void tst_QNetworkReply::downloadProgress() QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(reply->isFinished()); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); //final progress should have equal current & total QList<QVariant> args = spy.takeLast(); @@ -5654,14 +5654,14 @@ void tst_QNetworkReply::uploadProgress() QVERIFY(server.hasPendingConnections()); QTcpSocket *receiver = server.nextPendingConnection(); - if (finished.count() == 0) { + if (finished.size() == 0) { // it's not finished yet, so wait for it to be QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); } delete receiver; - QVERIFY(finished.count() > 0); - QVERIFY(spy.count() > 0); + QVERIFY(finished.size() > 0); + QVERIFY(spy.size() > 0); QList<QVariant> args = spy.last(); QCOMPARE(args.at(0).toInt(), data.size()); @@ -5943,8 +5943,8 @@ void tst_QNetworkReply::nestedEventLoops() QTestEventLoop::instance().enterLoop(20); QVERIFY2(!QTestEventLoop::instance().timeout(), "Network timeout"); - QCOMPARE(finishedspy.count(), 1); - QCOMPARE(errorspy.count(), 0); + QCOMPARE(finishedspy.size(), 1); + QCOMPARE(errorspy.size(), 0); } #if QT_CONFIG(networkproxy) @@ -5990,7 +5990,7 @@ void tst_QNetworkReply::httpProxyCommands() // especially since it won't succeed in the HTTPS case // so just check that the command was correct - QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length()); + QString receivedHeader = proxyServer.receivedData.left(expectedCommand.size()); QCOMPARE(receivedHeader, expectedCommand); //QTBUG-17223 - make sure the user agent from the request is sent to proxy server even for CONNECT @@ -6074,7 +6074,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous() // especially since it won't succeed in the HTTPS case // so just check that the command was correct - QString receivedHeader = proxyServer->receivedData.left(expectedCommand.length()); + QString receivedHeader = proxyServer->receivedData.left(expectedCommand.size()); QCOMPARE(receivedHeader, expectedCommand); } @@ -6171,9 +6171,9 @@ void tst_QNetworkReply::authorizationError() QCOMPARE(waitForFinish(reply), int(Failure)); QFETCH(int, errorSignalCount); - QCOMPARE(errorSpy.count(), errorSignalCount); + QCOMPARE(errorSpy.size(), errorSignalCount); QFETCH(int, finishedSignalCount); - QCOMPARE(finishedSpy.count(), finishedSignalCount); + QCOMPARE(finishedSpy.size(), finishedSignalCount); QFETCH(int, error); QCOMPARE(reply->error(), QNetworkReply::NetworkError(error)); @@ -6532,7 +6532,7 @@ void tst_QNetworkReply::encrypted() QTestEventLoop::instance().enterLoop(20); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); reply->deleteLater(); } @@ -6561,7 +6561,7 @@ void tst_QNetworkReply::abortOnEncrypted() }); QSignalSpy spyEncrypted(reply, &QNetworkReply::encrypted); - QTRY_COMPARE(spyEncrypted.count(), 1); + QTRY_COMPARE(spyEncrypted.size(), 1); // Wait for the socket to be closed again in order to be sure QTcpSocket::readyRead would have been emitted. QTRY_VERIFY(server.socket != nullptr); @@ -7144,9 +7144,9 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(authSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(authSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); } @@ -7157,7 +7157,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel_data() QTest::addColumn<QNetworkProxy>("proxy"); QTest::addColumn<bool>("proxyAuth"); QTest::addColumn<QUrl>("url"); - for (int i = 0; i < proxies.count(); ++i) { + for (int i = 0; i < proxies.size(); ++i) { QTest::newRow("http" + proxies.at(i).tag) << proxies.at(i).proxy << proxies.at(i).requiresAuthentication @@ -7240,8 +7240,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError); - QCOMPARE(authSpy.count(), 0); - QCOMPARE(proxyAuthSpy.count(), 1); + QCOMPARE(authSpy.size(), 0); + QCOMPARE(proxyAuthSpy.size(), 1); proxyAuthSpy.clear(); //should fail due to bad credentials @@ -7255,8 +7255,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() // Work round known quirk in the old test server (danted -v < v1.1.19): if (reply->error() != QNetworkReply::HostNotFoundError) QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError); - QCOMPARE(authSpy.count(), 0); - QVERIFY(proxyAuthSpy.count() > 0); + QCOMPARE(authSpy.size(), 0); + QVERIFY(proxyAuthSpy.size() > 0); proxyAuthSpy.clear(); // QTBUG-23136 workaround (needed even with danted v1.1.19): @@ -7281,10 +7281,10 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); - QVERIFY(authSpy.count() > 0); + QVERIFY(authSpy.size() > 0); authSpy.clear(); if (proxyAuth) { - QVERIFY(proxyAuthSpy.count() > 0); + QVERIFY(proxyAuthSpy.size() > 0); proxyAuthSpy.clear(); } @@ -7297,11 +7297,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); - QVERIFY(authSpy.count() > 0); + QVERIFY(authSpy.size() > 0); authSpy.clear(); if (proxyAuth) { //should be supplied from cache - QCOMPARE(proxyAuthSpy.count(), 0); + QCOMPARE(proxyAuthSpy.size(), 0); proxyAuthSpy.clear(); } @@ -7315,11 +7315,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(authSpy.count() > 0); + QVERIFY(authSpy.size() > 0); authSpy.clear(); if (proxyAuth) { //should be supplied from cache - QCOMPARE(proxyAuthSpy.count(), 0); + QCOMPARE(proxyAuthSpy.size(), 0); proxyAuthSpy.clear(); } @@ -7331,11 +7331,11 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QCOMPARE(reply->error(), QNetworkReply::NoError); //should be supplied from cache - QCOMPARE(authSpy.count(), 0); + QCOMPARE(authSpy.size(), 0); authSpy.clear(); if (proxyAuth) { //should be supplied from cache - QCOMPARE(proxyAuthSpy.count(), 0); + QCOMPARE(proxyAuthSpy.size(), 0); proxyAuthSpy.clear(); } @@ -7437,8 +7437,8 @@ void tst_QNetworkReply::httpWithNoCredentialUsage() QNetworkReplyPtr reply(manager.get(request)); QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); // credentials in URL, so don't expect authentication signal - QCOMPARE(authSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(authSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 1); finishedSpy.clear(); } @@ -7448,8 +7448,8 @@ void tst_QNetworkReply::httpWithNoCredentialUsage() QNetworkReplyPtr reply(manager.get(request)); QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); // credentials in cache, so don't expect authentication signal - QCOMPARE(authSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(authSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 1); finishedSpy.clear(); } @@ -7466,9 +7466,9 @@ void tst_QNetworkReply::httpWithNoCredentialUsage() QVERIFY(!QTestEventLoop::instance().timeout()); // We check if authenticationRequired was emitted, however we do not anything in it so it should be 401 - QCOMPARE(authSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(authSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); } @@ -7753,8 +7753,8 @@ void tst_QNetworkReply::qtbug45581WrongReplyStatusCode() QCOMPARE(reply->readAll(), expectedContent); - QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), expectedContent.size()); @@ -7843,8 +7843,8 @@ void tst_QNetworkReply::synchronousRequest() QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0)); QVERIFY(reply->isFinished()); - QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toString(), mimeType); @@ -7883,7 +7883,7 @@ void tst_QNetworkReply::synchronousRequestSslFailure() runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0); QVERIFY(reply->isFinished()); QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError); - QCOMPARE(sslErrorsSpy.count(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); } #endif @@ -8130,7 +8130,7 @@ void tst_QNetworkReply::dontInsertPartialContentIntoTheCache() QVERIFY(server.totalConnections > 0); QCOMPARE(reply->readAll().constData(), "load"); - QCOMPARE(memoryCache->m_insertedUrls.count(), 0); + QCOMPARE(memoryCache->m_insertedUrls.size(), 0); } void tst_QNetworkReply::httpUserAgent() @@ -8333,7 +8333,7 @@ void tst_QNetworkReply::emitErrorForAllReplies() // QTBUG-36890 QList<QNetworkReply *> replies; QList<QSignalSpy *> errorSpies; QList<QSignalSpy *> finishedSpies; - for (int a = 0; a < urls.count(); ++a) { + for (int a = 0; a < urls.size(); ++a) { QNetworkRequest request(urls.at(a)); QNetworkReply *reply = manager.get(request); replies.append(reply); @@ -8345,11 +8345,11 @@ void tst_QNetworkReply::emitErrorForAllReplies() // QTBUG-36890 } QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); - for (int a = 0; a < urls.count(); ++a) { + for (int a = 0; a < urls.size(); ++a) { QVERIFY(replies.at(a)->isFinished()); - QCOMPARE(errorSpies.at(a)->count(), 1); + QCOMPARE(errorSpies.at(a)->size(), 1); errorSpies.at(a)->deleteLater(); - QCOMPARE(finishedSpies.at(a)->count(), 1); + QCOMPARE(finishedSpies.at(a)->size(), 1); finishedSpies.at(a)->deleteLater(); replies.at(a)->deleteLater(); } @@ -8399,7 +8399,7 @@ public: return ret; } virtual bool atEnd() const override { return buffer.atEnd(); } - virtual qint64 size() const override { return data.length(); } + virtual qint64 size() const override { return data.size(); } qint64 bytesAvailable() const override { return buffer.bytesAvailable() + QIODevice::bytesAvailable(); @@ -8422,7 +8422,7 @@ void tst_QNetworkReply::putWithRateLimiting() QFile reference(testDataDir + "/rfc3252.txt"); reference.open(QIODevice::ReadOnly); QByteArray data = reference.readAll(); - QVERIFY(data.length() > 0); + QVERIFY(data.size() > 0); QUrl url = QUrl::fromUserInput("http://" + QtNetworkSettings::httpServerName()+ "/qtest/cgi-bin/echo.cgi?"); @@ -8437,7 +8437,7 @@ void tst_QNetworkReply::putWithRateLimiting() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QByteArray uploadedData = reply->readAll(); - QCOMPARE(uploadedData.length(), data.length()); + QCOMPARE(uploadedData.size(), data.size()); QCOMPARE(uploadedData, data); } @@ -8469,8 +8469,8 @@ void tst_QNetworkReply::ioHttpSingleRedirect() QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); // Redirected and finished should be emitted exactly once - QCOMPARE(redSpy.count(), 1); - QCOMPARE(finSpy.count(), 1); + QCOMPARE(redSpy.size(), 1); + QCOMPARE(finSpy.size(), 1); // Original URL should not be changed after redirect QCOMPARE(request.url(), localhost); @@ -8516,8 +8516,8 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects() QCOMPARE(waitForFinish(reply), int(Failure)); - QCOMPARE(redSpy.count(), request.maximumRedirectsAllowed()); - QCOMPARE(spy.count(), 1); + QCOMPARE(redSpy.size(), request.maximumRedirectsAllowed()); + QCOMPARE(spy.size(), 1); QCOMPARE(reply->error(), QNetworkReply::TooManyRedirectsError); // Increase max redirects to allow successful completion @@ -8528,7 +8528,7 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects() QVERIFY2(waitForFinish(reply2) == Success, msgWaitForFinished(reply2)); - QCOMPARE(redSpy2.count(), 2); + QCOMPARE(redSpy2.size(), 2); QCOMPARE(reply2->url(), server3Url); QCOMPARE(reply2->error(), QNetworkReply::NoError); QVERIFY(validateRedirectedResponseHeaders(reply2)); @@ -8661,8 +8661,8 @@ void tst_QNetworkReply::ioHttpRedirectPolicy() QSignalSpy redirectSpy(reply.data(), SIGNAL(redirected(QUrl))); QSignalSpy finishedSpy(reply.data(), SIGNAL(finished())); QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(redirectSpy.count(), redirectCount); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(redirectSpy.size(), redirectCount); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200); } @@ -8745,7 +8745,7 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors() QSignalSpy spy(reply.data(), SIGNAL(errorOccurred(QNetworkReply::NetworkError))); QCOMPARE(waitForFinish(reply), int(Failure)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(reply->error(), expectedError); } @@ -8795,7 +8795,7 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect() QSignalSpy finishedSpy(reply.data(), SIGNAL(finished())); waitForFinish(reply); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(finishedSpy.size(), 1); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); QVERIFY(validateRedirectedResponseHeaders(reply) || statusCode != 200); } @@ -8807,7 +8807,7 @@ void tst_QNetworkReply::ioHttpCookiesDuringRedirect() const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n"); QString redirect = tempRedirectReplyStr(); // Insert 'cookieHeader' before the final \r\n - redirect.insert(redirect.length() - 2, cookieHeader); + redirect.insert(redirect.size() - 2, cookieHeader); QUrl url("http://localhost/"); url.setPort(target.serverPort()); @@ -9234,7 +9234,7 @@ public slots: //qDebug() << m_receivedData.left(m_receivedData.indexOf("\r\n\r\n")); m_receivedData = m_receivedData.mid(m_receivedData.indexOf("\r\n\r\n")+4); // check only actual data } - if (m_receivedData.length() > 0 && !m_expectedData.startsWith(m_receivedData)) { + if (m_receivedData.size() > 0 && !m_expectedData.startsWith(m_receivedData)) { // We had received some data but it is corrupt! qDebug() << "CORRUPT" << m_receivedData.size(); @@ -9386,7 +9386,7 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute() QSignalSpy finishedSpy(reply, &QNetworkReply::finished); QSignalSpy destroyedSpy(reply, &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QVERIFY(destroyedSpy.wait()); } { @@ -9397,7 +9397,7 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute() QSignalSpy finishedSpy(reply, &QNetworkReply::finished); QSignalSpy destroyedSpy(reply, &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QVERIFY(destroyedSpy.wait()); } // Now repeated, but without the attribute to make sure it does not get deleted automatically. @@ -9411,10 +9411,10 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } { // Post @@ -9423,10 +9423,10 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } } @@ -9447,7 +9447,7 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply, &QNetworkReply::finished); QSignalSpy destroyedSpy(reply, &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QVERIFY(destroyedSpy.wait()); } { @@ -9457,7 +9457,7 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply, &QNetworkReply::finished); QSignalSpy destroyedSpy(reply, &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QVERIFY(destroyedSpy.wait()); } // Here we repeat the test, but override the auto-deletion in the QNetworkRequest @@ -9472,10 +9472,10 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } { // Post @@ -9485,10 +9485,10 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } // Now we repeat the test with autoDeleteReplies set to false cleanup.dismiss(); @@ -9500,10 +9500,10 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } { // Post @@ -9512,10 +9512,10 @@ void tst_QNetworkReply::autoDeleteReplies() QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); QVERIFY(finishedSpy.wait()); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); QCoreApplication::processEvents(); QCoreApplication::processEvents(); - QCOMPARE(destroyedSpy.count(), 0); + QCOMPARE(destroyedSpy.size(), 0); } } @@ -9529,7 +9529,7 @@ void tst_QNetworkReply::getWithTimeout() QCOMPARE(waitForFinish(reply), int(Success)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(reply->error() == QNetworkReply::NoError); request.setTransferTimeout(1000); @@ -9540,7 +9540,7 @@ void tst_QNetworkReply::getWithTimeout() QCOMPARE(waitForFinish(reply2), int(Failure)); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QVERIFY(reply2->error() == QNetworkReply::OperationCanceledError); request.setTransferTimeout(0); @@ -9551,7 +9551,7 @@ void tst_QNetworkReply::getWithTimeout() QCOMPARE(waitForFinish(reply3), int(Failure)); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.size(), 1); QVERIFY(reply3->error() == QNetworkReply::OperationCanceledError); manager.setTransferTimeout(0); @@ -9569,7 +9569,7 @@ void tst_QNetworkReply::postWithTimeout() QCOMPARE(waitForFinish(reply), int(Success)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(reply->error() == QNetworkReply::NoError); request.setTransferTimeout(1000); @@ -9580,7 +9580,7 @@ void tst_QNetworkReply::postWithTimeout() QCOMPARE(waitForFinish(reply2), int(Failure)); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QVERIFY(reply2->error() == QNetworkReply::OperationCanceledError); request.setTransferTimeout(0); @@ -9591,7 +9591,7 @@ void tst_QNetworkReply::postWithTimeout() QCOMPARE(waitForFinish(reply3), int(Failure)); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.size(), 1); QVERIFY(reply3->error() == QNetworkReply::OperationCanceledError); manager.setTransferTimeout(0); @@ -9636,13 +9636,13 @@ void tst_QNetworkReply::moreActivitySignals() QSignalSpy spy3(reply.data(), SIGNAL(metaDataChanged())); QSignalSpy spy4(reply.data(), SIGNAL(finished())); spy1.wait(); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); spy2.wait(); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); spy3.wait(); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.size(), 1); spy4.wait(); - QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.size(), 1); QVERIFY(reply->error() == QNetworkReply::NoError); // Second request will not send socketStartedConnecting because of keep-alive, so don't check it. QNetworkReplyPtr secondreply; @@ -9656,11 +9656,11 @@ void tst_QNetworkReply::moreActivitySignals() QSignalSpy secondspy3(secondreply.data(), SIGNAL(metaDataChanged())); QSignalSpy secondspy4(secondreply.data(), SIGNAL(finished())); secondspy2.wait(); - QCOMPARE(secondspy2.count(), 1); + QCOMPARE(secondspy2.size(), 1); secondspy3.wait(); - QCOMPARE(secondspy3.count(), 1); + QCOMPARE(secondspy3.size(), 1); secondspy4.wait(); - QCOMPARE(secondspy4.count(), 1); + QCOMPARE(secondspy4.size(), 1); QVERIFY(secondreply->error() == QNetworkReply::NoError); } diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index b1867d55fb..d22d858b26 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -66,7 +66,7 @@ QString tst_QDnsLookup::domainNameList(const QString &input) QStringList tst_QDnsLookup::domainNameListAlternatives(const QString &input) { QStringList alternatives = input.split('|'); - for (int i = 0; i < alternatives.length(); ++i) + for (int i = 0; i < alternatives.size(); ++i) alternatives[i] = domainNameList(alternatives[i]); return alternatives; } @@ -367,7 +367,7 @@ void tst_QDnsLookup::bindingsAndProperties() const QSignalSpy typeChangeSpy(&lookup, &QDnsLookup::typeChanged); dnsTypeProp = QDnsLookup::AAAA; - QCOMPARE(typeChangeSpy.count(), 1); + QCOMPARE(typeChangeSpy.size(), 1); QCOMPARE(lookup.type(), QDnsLookup::AAAA); dnsTypeProp.setBinding(lookup.bindableType().makeBinding()); @@ -379,7 +379,7 @@ void tst_QDnsLookup::bindingsAndProperties() const QSignalSpy nameChangeSpy(&lookup, &QDnsLookup::nameChanged); nameProp = QStringLiteral("a-plus-aaaa"); - QCOMPARE(nameChangeSpy.count(), 1); + QCOMPARE(nameChangeSpy.size(), 1); QCOMPARE(lookup.name(), QStringLiteral("a-plus-aaaa")); nameProp.setBinding(lookup.bindableName().makeBinding()); @@ -391,7 +391,7 @@ void tst_QDnsLookup::bindingsAndProperties() const QSignalSpy nameserverChangeSpy(&lookup, &QDnsLookup::nameserverChanged); nameserverProp = QHostAddress::LocalHost; - QCOMPARE(nameserverChangeSpy.count(), 1); + QCOMPARE(nameserverChangeSpy.size(), 1); QCOMPARE(lookup.nameserver(), QHostAddress::LocalHost); nameserverProp.setBinding(lookup.bindableNameserver().makeBinding()); diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index f5d1c1cb5e..3564e52917 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -227,7 +227,7 @@ void tst_QHostInfo::lookupIPv4() QCOMPARE((int)lookupResults.error(), (int)err); QStringList tmp; - for (int i = 0; i < lookupResults.addresses().count(); ++i) + for (int i = 0; i < lookupResults.addresses().size(); ++i) tmp.append(lookupResults.addresses().at(i).toString()); tmp.sort(); @@ -272,7 +272,7 @@ void tst_QHostInfo::lookupIPv6() QCOMPARE((int)lookupResults.error(), (int)err); QStringList tmp; - for (int i = 0; i < lookupResults.addresses().count(); ++i) + for (int i = 0; i < lookupResults.addresses().size(); ++i) tmp.append(lookupResults.addresses().at(i).toString()); tmp.sort(); @@ -351,7 +351,7 @@ void tst_QHostInfo::lookupConnectToLambda() QCOMPARE(int(lookupResults.error()), int(err)); QStringList tmp; - for (int i = 0; i < lookupResults.addresses().count(); ++i) + for (int i = 0; i < lookupResults.addresses().size(); ++i) tmp.append(lookupResults.addresses().at(i).toString()); tmp.sort(); @@ -405,12 +405,12 @@ static QStringList reverseLookupHelper(const QString &ip) for (QByteArray line : lines) { int index = -1; if ((index = line.indexOf(nameMarkerNix)) != -1) { // Linux and macOS - name = line.mid(index + nameMarkerNix.length()).chopped(1).trimmed(); + name = line.mid(index + nameMarkerNix.size()).chopped(1).trimmed(); results << name; } else if (line.startsWith(nameMarkerWin)) { // Windows formatting name = line.mid(line.lastIndexOf(" ")).trimmed(); } else if (line.startsWith(addressMarkerWin)) { - QByteArray address = line.mid(addressMarkerWin.length()).trimmed(); + QByteArray address = line.mid(addressMarkerWin.size()).trimmed(); if (address == ip.toUtf8()) { results << name; } @@ -477,7 +477,7 @@ void tst_QHostInfo::blockingLookup() QHostInfo hostInfo = QHostInfo::fromName(hostname); QStringList tmp; - for (int i = 0; i < hostInfo.addresses().count(); ++i) + for (int i = 0; i < hostInfo.addresses().size(); ++i) tmp.append(hostInfo.addresses().at(i).toString()); tmp.sort(); @@ -507,7 +507,7 @@ protected: { QHostInfo info = QHostInfo::fromName("a-single" TEST_DOMAIN); QCOMPARE(info.error(), QHostInfo::NoError); - QVERIFY(info.addresses().count() > 0); + QVERIFY(info.addresses().size() > 0); QCOMPARE(info.addresses().at(0).toString(), QString("192.0.2.1")); } }; @@ -566,7 +566,7 @@ void tst_QHostInfo::threadSafetyAsynchronousAPI() thread->start(); threads.append(thread); } - for (int k = threads.count() - 1; k >= 0; --k) + for (int k = threads.size() - 1; k >= 0; --k) QVERIFY(threads.at(k)->wait(60000)); foreach (LookupReceiver* receiver, receivers) { QCOMPARE(receiver->result.error(), QHostInfo::NoError); diff --git a/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp b/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp index cde2399424..720388c53f 100644 --- a/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp +++ b/tests/auto/network/kernel/qnetworkinformation/tst_qnetworkinformation.cpp @@ -241,14 +241,14 @@ void tst_QNetworkInformation::isMetered() QSignalSpy spy(info, &QNetworkInformation::isMeteredChanged); QVERIFY(!info->isMetered()); MockBackend::setNewMetered(true); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(info->isMetered()); QVERIFY(spy[0][0].toBool()); spy.clear(); // Set the same value again, signal should not be emitted again MockBackend::setNewMetered(true); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } QTEST_MAIN(tst_QNetworkInformation); diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index d609bf5877..36027d89da 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -251,7 +251,7 @@ void tst_QNetworkInterface::interfaceFromXXX_data() QTest::addColumn<QNetworkInterface>("iface"); QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces(); - if (allInterfaces.count() == 0) + if (allInterfaces.size() == 0) QSKIP("No interfaces to test!"); foreach (QNetworkInterface iface, allInterfaces) QTest::newRow(iface.name().toLocal8Bit()) << iface; diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 63bd17f130..c9bf8b92f3 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -83,9 +83,9 @@ public slots: int idx = client->property("dataTransmitionIdx").toInt(); if (receivedData.contains("\r\n\r\n") || receivedData.contains("\n\n")) { - if (idx < dataToTransmit.length()) + if (idx < dataToTransmit.size()) client->write(dataToTransmit.at(idx++)); - if (idx == dataToTransmit.length()) { + if (idx == dataToTransmit.size()) { client->disconnectFromHost(); disconnect(client, 0, this, 0); client = 0; diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 9b8fec384c..7e523cfadf 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -245,8 +245,8 @@ void tst_QLocalSocket::server_basic() QVERIFY(!timedOut); QCOMPARE(server.listen(QString()), false); - QCOMPARE(server.hits.count(), 0); - QCOMPARE(spyNewConnection.count(), 0); + QCOMPARE(server.hits.size(), 0); + QCOMPARE(spyNewConnection.size(), 0); } void tst_QLocalSocket::server_connectionsCount() @@ -287,11 +287,11 @@ void tst_QLocalSocket::socket_basic() QCOMPARE(socket.waitForDisconnected(0), false); QCOMPARE(socket.waitForReadyRead(0), false); - QCOMPARE(spyConnected.count(), 0); - QCOMPARE(spyDisconnected.count(), 0); - QCOMPARE(spyError.count(), 0); - QCOMPARE(spyStateChanged.count(), 0); - QCOMPARE(spyReadyRead.count(), 0); + QCOMPARE(spyConnected.size(), 0); + QCOMPARE(spyDisconnected.size(), 0); + QCOMPARE(spyError.size(), 0); + QCOMPARE(spyStateChanged.size(), 0); + QCOMPARE(spyReadyRead.size(), 0); } void tst_QLocalSocket::listen_data() @@ -321,8 +321,8 @@ void tst_QLocalSocket::listen() QCOMPARE(server.isListening(), canListen); QCOMPARE(server.hasPendingConnections(), false); QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0); - QCOMPARE(server.hits.count(), 0); - QCOMPARE(spyNewConnection.count(), 0); + QCOMPARE(server.hits.size(), 0); + QCOMPARE(spyNewConnection.size(), 0); if (canListen) { QVERIFY(server.errorString().isEmpty()); QCOMPARE(server.serverError(), QAbstractSocket::UnknownSocketError); @@ -396,7 +396,7 @@ void tst_QLocalSocket::listenAndConnect() QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::ConnectedState); //QVERIFY(socket->socketDescriptor() != -1); - QCOMPARE(spyError.count(), 0); + QCOMPARE(spyError.size(), 0); } else { QVERIFY(!socket->errorString().isEmpty()); QVERIFY(socket->error() != QLocalSocket::UnknownSocketError); @@ -415,13 +415,13 @@ void tst_QLocalSocket::listenAndConnect() QCOMPARE(socket->waitForConnected(0), canListen); QCOMPARE(socket->waitForReadyRead(0), false); - QTRY_COMPARE(spyConnected.count(), canListen ? 1 : 0); - QCOMPARE(spyDisconnected.count(), 0); + QTRY_COMPARE(spyConnected.size(), canListen ? 1 : 0); + QCOMPARE(spyDisconnected.size(), 0); // error signals - QVERIFY(spyError.count() >= 0); + QVERIFY(spyError.size() >= 0); if (canListen) { - if (spyError.count() > 0) + if (spyError.size() > 0) QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QLocalSocket::SocketTimeoutError); } else { @@ -436,8 +436,8 @@ void tst_QLocalSocket::listenAndConnect() if (canListen) QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketState>(spyStateChanged.last()[0]), QLocalSocket::ConnectedState); - QCOMPARE(spyStateChanged.count(), 2); - QCOMPARE(spyReadyRead.count(), 0); + QCOMPARE(spyStateChanged.size(), 2); + QCOMPARE(spyReadyRead.size(), 0); bool timedOut = true; QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen); @@ -451,16 +451,16 @@ void tst_QLocalSocket::listenAndConnect() QCOMPARE(server.serverName(), name); QVERIFY(server.fullServerName().contains(name)); QVERIFY(server.nextPendingConnection() != (QLocalSocket*)0); - QTRY_COMPARE(server.hits.count(), i + 1); - QCOMPARE(spyNewConnection.count(), i + 1); + QTRY_COMPARE(server.hits.size(), i + 1); + QCOMPARE(spyNewConnection.size(), i + 1); QVERIFY(server.errorString().isEmpty()); QCOMPARE(server.serverError(), QAbstractSocket::UnknownSocketError); } else { QVERIFY(server.serverName().isEmpty()); QVERIFY(server.fullServerName().isEmpty()); QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0); - QCOMPARE(spyNewConnection.count(), 0); - QCOMPARE(server.hits.count(), 0); + QCOMPARE(spyNewConnection.size(), 0); + QCOMPARE(server.hits.size(), 0); QVERIFY(!server.errorString().isEmpty()); QCOMPARE(server.serverError(), QAbstractSocket::HostNotFoundError); } @@ -469,8 +469,8 @@ void tst_QLocalSocket::listenAndConnect() server.close(); - QCOMPARE(server.hits.count(), (canListen ? connections : 0)); - QCOMPARE(spyNewConnection.count(), (canListen ? connections : 0)); + QCOMPARE(server.hits.size(), (canListen ? connections : 0)); + QCOMPARE(spyNewConnection.size(), (canListen ? connections : 0)); } void tst_QLocalSocket::connectWithOpen() @@ -494,7 +494,7 @@ void tst_QLocalSocket::connectWithOpen() socket.close(); server.close(); - QCOMPARE(spyAboutToClose.count(), 1); + QCOMPARE(spyAboutToClose.size(), 1); } void tst_QLocalSocket::listenAndConnectAbstractNamespaceTrailingZeros_data() @@ -660,7 +660,7 @@ void tst_QLocalSocket::sendData() QTest::qWait(250); #endif QVERIFY(!timedOut); - QCOMPARE(spyConnected.count(), canListen ? 1 : 0); + QCOMPARE(spyConnected.size(), canListen ? 1 : 0); QCOMPARE(socket.state(), canListen ? QLocalSocket::ConnectedState : QLocalSocket::UnconnectedState); // test sending/receiving data @@ -686,7 +686,7 @@ void tst_QLocalSocket::sendData() QCOMPARE(socket.flush(), false); QCOMPARE(socket.isValid(), canListen); QCOMPARE(socket.readBufferSize(), (qint64)0); - QCOMPARE(spyReadyRead.count(), expectedReadyReadSignals); + QCOMPARE(spyReadyRead.size(), expectedReadyReadSignals); QVERIFY(testLine.startsWith(in.readLine())); @@ -697,16 +697,16 @@ void tst_QLocalSocket::sendData() } socket.disconnectFromServer(); - QCOMPARE(spyConnected.count(), canListen ? 1 : 0); - QCOMPARE(spyDisconnected.count(), canListen ? 1 : 0); - QCOMPARE(spyError.count(), canListen ? 0 : 1); - QCOMPARE(spyStateChanged.count(), canListen ? 4 : 2); - QCOMPARE(spyReadyRead.count(), canListen ? expectedReadyReadSignals : 0); + QCOMPARE(spyConnected.size(), canListen ? 1 : 0); + QCOMPARE(spyDisconnected.size(), canListen ? 1 : 0); + QCOMPARE(spyError.size(), canListen ? 0 : 1); + QCOMPARE(spyStateChanged.size(), canListen ? 4 : 2); + QCOMPARE(spyReadyRead.size(), canListen ? expectedReadyReadSignals : 0); server.close(); - QCOMPARE(server.hits.count(), (canListen ? 1 : 0)); - QCOMPARE(spy.count(), (canListen ? 1 : 0)); + QCOMPARE(server.hits.size(), (canListen ? 1 : 0)); + QCOMPARE(spy.size(), (canListen ? 1 : 0)); } void tst_QLocalSocket::readLine_data() @@ -1006,7 +1006,7 @@ void tst_QLocalSocket::simpleCommandProtocol2() localSocketWrite.abort(); QCOMPARE(localSocketWrite.state(), QLocalSocket::UnconnectedState); - QCOMPARE(spyDisconnected.count(), 1); + QCOMPARE(spyDisconnected.size(), 1); QCOMPARE(localSocketWrite.bytesToWrite(), 0); QVERIFY(!localSocketWrite.isOpen()); @@ -1068,7 +1068,7 @@ void tst_QLocalSocket::hitMaximumConnections() bool timedOut = true; QVERIFY(server.waitForNewConnection(3000, &timedOut)); QVERIFY(!timedOut); - QVERIFY(server.hits.count() > 0); + QVERIFY(server.hits.size() > 0); qDeleteAll(sockets.begin(), sockets.end()); } @@ -1096,9 +1096,9 @@ public: QVERIFY(socket.waitForConnected(1000)); // We should *not* have this signal yet! - QCOMPARE(spyReadyRead.count(), 0); + QCOMPARE(spyReadyRead.size(), 0); socket.waitForReadyRead(); - QCOMPARE(spyReadyRead.count(), 1); + QCOMPARE(spyReadyRead.size(), 1); QTextStream in(&socket); QCOMPARE(in.readLine(), testLine); socket.close(); @@ -1140,7 +1140,7 @@ public: --done; delete serverSocket; } - QCOMPARE(server.hits.count(), clients); + QCOMPARE(server.hits.size(), clients); } }; @@ -1309,7 +1309,7 @@ void tst_QLocalSocket::waitForDisconnectByServer() serverSocket->close(); QCOMPARE(serverSocket->state(), QLocalSocket::UnconnectedState); QVERIFY(socket.waitForDisconnected(3000)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QLocalSocket::waitForReadyReadOnDisconnected() @@ -1426,7 +1426,7 @@ void tst_QLocalSocket::recycleClientSocket() QLocalSocket client; QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead())); QSignalSpy clientErrorSpy(&client, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError))); - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { client.abort(); clientReadyReadSpy.clear(); client.connectToServer(serverName); @@ -1521,7 +1521,7 @@ void tst_QLocalSocket::writeToClientAndDisconnect() QVERIFY(clientSocket->waitForDisconnected()); QVERIFY(client.waitForDisconnected()); - QCOMPARE(readChannelFinishedSpy.count(), 1); + QCOMPARE(readChannelFinishedSpy.size(), 1); const QByteArray received = client.readAll(); QCOMPARE(received.size(), qint64(sizeof(buffer) * chunks)); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); @@ -1551,7 +1551,7 @@ void tst_QLocalSocket::writeToDisconnected() QCOMPARE(client.bytesToWrite(), qint64(1)); QVERIFY(!client.waitForBytesWritten()); - QCOMPARE(spyError.count(), 1); + QCOMPARE(spyError.size(), 1); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } @@ -1656,7 +1656,7 @@ void tst_QLocalSocket::asyncDisconnectNotify() QVERIFY(serverSocket); delete serverSocket; QTRY_VERIFY(!disconnectedSpy.isEmpty()); - QCOMPARE(readChannelFinishedSpy.count(), 1); + QCOMPARE(readChannelFinishedSpy.size(), 1); } void tst_QLocalSocket::verifySocketOptions_data() diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 3ce1153031..aa860893bb 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -915,13 +915,13 @@ void tst_QSocks5SocketEngine::fragmentation_data() responses << authMethodBasic << authSuccess.left(1) << authSuccess.mid(1) << connectResponseIPv4; QTest::newRow("auth-response") << responses; - for (int i = 1; i < connectResponseIPv4.length() - 1; i++) { + for (int i = 1; i < connectResponseIPv4.size() - 1; i++) { responses.clear(); responses << authMethodNone << connectResponseIPv4.left(i) << connectResponseIPv4.mid(i); QTest::newRow(qPrintable(QString("connect-response-ipv4-") + QString::number(i))) << responses; } - for (int i = 1; i < connectResponseIPv6.length() - 1; i++) { + for (int i = 1; i < connectResponseIPv6.size() - 1; i++) { responses.clear(); responses << authMethodNone << connectResponseIPv6.left(i) << connectResponseIPv6.mid(i); QTest::newRow(qPrintable(QString("connect-response-ipv6-") + QString::number(i))) << responses; @@ -964,13 +964,13 @@ void tst_QSocks5SocketEngine::incomplete_data() responses << authMethodBasic << authSuccess.left(1); QTest::newRow("auth-response") << responses; - for (int i = 1; i < connectResponseIPv4.length() - 1; i++) { + for (int i = 1; i < connectResponseIPv4.size() - 1; i++) { responses.clear(); responses << authMethodNone << connectResponseIPv4.left(i); QTest::newRow(qPrintable(QString("connect-response-ipv4-") + QString::number(i))) << responses; } - for (int i = 1; i < connectResponseIPv6.length() - 1; i++) { + for (int i = 1; i < connectResponseIPv6.size() - 1; i++) { responses.clear(); responses << authMethodNone << connectResponseIPv6.left(i); QTest::newRow(qPrintable(QString("connect-response-ipv6-") + QString::number(i))) << responses; diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 5c87a3f04b..b10bce335b 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -248,7 +248,7 @@ void tst_QTcpServer::clientServerLoop() QVERIFY(server.waitForNewConnection(5000)); QVERIFY(server.hasPendingConnections()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTcpSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket != 0); @@ -409,9 +409,9 @@ void tst_QTcpServer::maxPendingConnections() // two connections have been made. The second compare makes sure no // more are accepted. Creating connections happens multithreaded so // qWait must be used for that. - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.size(), 2); QTest::qWait(100); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(server.hasPendingConnections()); QVERIFY(server.nextPendingConnection()); @@ -1016,12 +1016,12 @@ void tst_QTcpServer::eagainBlockingAccept() QTcpSocket s; s.connectToHost(QHostAddress::LocalHost, 7896); QSignalSpy spy(&server, SIGNAL(newConnection())); - QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 500); + QTRY_COMPARE_WITH_TIMEOUT(spy.size(), 1, 500); s.close(); // To test try again, should connect just fine. s.connectToHost(QHostAddress::LocalHost, 7896); - QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 500); + QTRY_COMPARE_WITH_TIMEOUT(spy.size(), 2, 500); s.close(); server.close(); } @@ -1057,13 +1057,13 @@ void tst_QTcpServer::pauseAccepting() QTcpSocket sockets[NumSockets]; sockets[0].connectToHost(address, server.serverPort()); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); server.pauseAccepting(); for (int i = 1; i < NumSockets; ++i) sockets[i].connectToHost(address, server.serverPort()); QVERIFY(!spy.wait(400)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); server.resumeAccepting(); if (setProxy) { @@ -1071,7 +1071,7 @@ void tst_QTcpServer::pauseAccepting() Abort); } QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 6); + QCOMPARE(spy.size(), 6); } @@ -1135,11 +1135,11 @@ void tst_QTcpServer::pendingConnectionAvailable() QCOMPARE(socket.state(), QTcpSocket::ConnectedState); int expectedPendingConnections = useDerivedServer ? 0 : 1; - QCOMPARE(pendingConnectionSpy.count(), expectedPendingConnections); + QCOMPARE(pendingConnectionSpy.size(), expectedPendingConnections); if (useDerivedServer) static_cast<DerivedServer *>(server)->emitNextSocket(); - QCOMPARE(pendingConnectionSpy.count(), 1); + QCOMPARE(pendingConnectionSpy.size(), 1); } QTEST_MAIN(tst_QTcpServer) diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 981160ce6b..e35c771b0b 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -347,8 +347,8 @@ void tst_QTcpSocket::init() QFETCH_GLOBAL(int, proxyType); QList<QHostAddress> socks5Addresses = QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses(); QList<QHostAddress> httpProxyAddresses = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName()).addresses(); - QVERIFY2(socks5Addresses.count() > 0, "failed to get ip address for SOCKS5 proxy server"); - QVERIFY2(httpProxyAddresses.count() > 0, "failed to get ip address for HTTP proxy server"); + QVERIFY2(socks5Addresses.size() > 0, "failed to get ip address for SOCKS5 proxy server"); + QVERIFY2(httpProxyAddresses.size() > 0, "failed to get ip address for HTTP proxy server"); QString socks5Address = socks5Addresses.first().toString(); QString httpProxyAddress = httpProxyAddresses.first().toString(); QNetworkProxy proxy; @@ -1781,7 +1781,7 @@ void tst_QTcpSocket::recursiveReadyRead() QVERIFY2(!timeout(), "Timed out when waiting for the readyRead() signal."); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); delete testSocket; } @@ -1823,7 +1823,7 @@ void tst_QTcpSocket::atEnd() QVERIFY2(greeting.startsWith("220 (vsFTPd 3."), qPrintable(greeting)); #else // Test server must use some vsFTPd 2.x.x version - QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); + QVERIFY2(greeting.size() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); #endif QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting)); @@ -2006,8 +2006,8 @@ void tst_QTcpSocket::remoteCloseError() enterLoop(30); QVERIFY(!timeout()); - QCOMPARE(disconnectedSpy.count(), 1); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(disconnectedSpy.size(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(clientSocket->error(), QAbstractSocket::RemoteHostClosedError); delete serverSocket; @@ -2138,7 +2138,7 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot() if (tmpSocket->state() != QAbstractSocket::ConnectedState) loop.exec(); - QCOMPARE(timerSpy.count(), 0); + QCOMPARE(timerSpy.size(), 0); delete tmpSocket; } @@ -2243,7 +2243,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() // Wait for the read QVERIFY(socket->waitForReadyRead(10000)); - QCOMPARE(readyReadSpy.count(), 1); + QCOMPARE(readyReadSpy.size(), 1); QString s = socket->readLine(); QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData()); @@ -2251,7 +2251,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QCoreApplication::instance()->processEvents(); QCOMPARE(socket->bytesAvailable(), qint64(0)); - QCOMPARE(readyReadSpy.count(), 1); + QCOMPARE(readyReadSpy.size(), 1); delete socket; } @@ -2325,8 +2325,8 @@ void tst_QTcpSocket::abortiveClose() enterLoop(5); - QCOMPARE(readyReadSpy.count(), 0); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(readyReadSpy.size(), 0); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(*static_cast<const int *>(errorSpy.at(0).at(0).constData()), int(QAbstractSocket::RemoteHostClosedError)); @@ -2445,11 +2445,11 @@ void tst_QTcpSocket::connectionRefused() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError); - QCOMPARE(stateSpy.count(), 3); + QCOMPARE(stateSpy.size(), 3); QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState); QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(errorSpy.size(), 1); delete socket; } @@ -3118,8 +3118,8 @@ void tst_QTcpSocket::serverDisconnectWithBuffered() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } // Test signal emitting - QCOMPARE(spyDisconnected.count(), 1); - QVERIFY(spyStateChanged.count() > 0); + QCOMPARE(spyDisconnected.size(), 1); + QVERIFY(spyStateChanged.size() > 0); QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first()) == QAbstractSocket::UnconnectedState); @@ -3208,7 +3208,7 @@ void tst_QTcpSocket::readNotificationsAfterBind() QTestEventLoop::instance().enterLoop(10); QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); - QCOMPARE(spyReadyRead.count(), 0); + QCOMPARE(spyReadyRead.size(), 0); } QTEST_MAIN(tst_QTcpSocket) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index a7928cfe32..5f8d220272 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -334,7 +334,7 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() QSignalSpy stateChangedSpy(&serverSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState))); QVERIFY2(serverSocket.bind(), serverSocket.errorString().toLatin1().constData()); - QCOMPARE(stateChangedSpy.count(), 1); + QCOMPARE(stateChangedSpy.size(), 1); const char *message[] = {"Yo mista", "Yo", "Wassap"}; @@ -386,7 +386,7 @@ void tst_QUdpSocket::broadcasting() foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) { if ((iface.flags() & QNetworkInterface::CanBroadcast) && iface.flags() & QNetworkInterface::IsUp) { - for (int i=0;i<iface.addressEntries().count();i++) { + for (int i=0;i<iface.addressEntries().size();i++) { QHostAddress broadcast = iface.addressEntries().at(i).broadcast(); if (broadcast.protocol() == QAbstractSocket::IPv4Protocol) broadcastAddresses.append(broadcast); @@ -431,7 +431,7 @@ void tst_QUdpSocket::broadcasting() QVERIFY(dgram.isValid()); QByteArray arr = dgram.data(); - QCOMPARE(arr.length(), messageLength); + QCOMPARE(arr.size(), messageLength); arr.resize(messageLength); QCOMPARE(arr, QByteArray(message[i])); @@ -491,27 +491,27 @@ void tst_QUdpSocket::loop() QHostAddress peterAddress = makeNonAny(peter.localAddress()); QHostAddress paulAddress = makeNonAny(paul.localAddress()); - QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), - paulAddress, paul.localPort()), qint64(peterMessage.length())); - QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), - peterAddress, peter.localPort()), qint64(paulMessage.length())); + QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.size(), + paulAddress, paul.localPort()), qint64(peterMessage.size())); + QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.size(), + peterAddress, peter.localPort()), qint64(paulMessage.size())); QVERIFY2(peter.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(peter).constData()); QVERIFY2(paul.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(paul).constData()); - QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2); - QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2); + QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.size() * 2); + QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.size() * 2); if (success) { - QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length())); - QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length())); + QCOMPARE(peterDatagram.data().size(), qint64(paulMessage.size())); + QCOMPARE(paulDatagram.data().size(), qint64(peterMessage.size())); } else { // this code path seems to never be executed - QVERIFY(peterDatagram.data().length() != paulMessage.length()); - QVERIFY(paulDatagram.data().length() != peterMessage.length()); + QVERIFY(peterDatagram.data().size() != paulMessage.size()); + QVERIFY(paulDatagram.data().size() != peterMessage.size()); } - QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage); - QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage); + QCOMPARE(peterDatagram.data().left(paulMessage.size()), paulMessage); + QCOMPARE(paulDatagram.data().left(peterMessage.size()), peterMessage); QCOMPARE(peterDatagram.senderAddress(), paulAddress); QCOMPARE(paulDatagram.senderAddress(), peterAddress); @@ -568,27 +568,27 @@ void tst_QUdpSocket::ipv6Loop() peterPort = peter.localPort(); paulPort = paul.localPort(); - QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"), - paulPort), qint64(peterMessage.length())); - QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), - QHostAddress("::1"), peterPort), qint64(paulMessage.length())); + QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.size(), QHostAddress("::1"), + paulPort), qint64(peterMessage.size())); + QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.size(), + QHostAddress("::1"), peterPort), qint64(paulMessage.size())); QVERIFY(peter.waitForReadyRead(5000)); QVERIFY(paul.waitForReadyRead(5000)); - QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2); - QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2); + QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.size() * 2); + QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.size() * 2); if (success) { - QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length())); - QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length())); + QCOMPARE(peterDatagram.data().size(), qint64(paulMessage.size())); + QCOMPARE(paulDatagram.data().size(), qint64(peterMessage.size())); } else { // this code path seems to never be executed - QVERIFY(peterDatagram.data().length() != paulMessage.length()); - QVERIFY(paulDatagram.data().length() != peterMessage.length()); + QVERIFY(peterDatagram.data().size() != paulMessage.size()); + QVERIFY(paulDatagram.data().size() != peterMessage.size()); } - QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage); - QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage); + QCOMPARE(peterDatagram.data().left(paulMessage.size()), paulMessage); + QCOMPARE(paulDatagram.data().left(peterMessage.size()), peterMessage); QCOMPARE(peterDatagram.senderAddress(), paulAddress); QCOMPARE(paulDatagram.senderAddress(), peterAddress); @@ -616,7 +616,7 @@ void tst_QUdpSocket::dualStack() QVERIFY(v4Sock.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); //test v4 -> dual - QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.length()); + QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.size(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.size()); QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); QNetworkDatagram dgram = dualSock.receiveDatagram(100); QVERIFY(dgram.isValid()); @@ -639,7 +639,7 @@ void tst_QUdpSocket::dualStack() QVERIFY(v6Sock.bind(QHostAddress(QHostAddress::AnyIPv6), 0)); //test v6 -> dual - QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.length(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.length()); + QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.size(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.size()); QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); dgram = dualSock.receiveDatagram(100); QVERIFY(dgram.isValid()); @@ -650,7 +650,7 @@ void tst_QUdpSocket::dualStack() QCOMPARE(dgram.destinationAddress(), makeNonAny(dualSock.localAddress(), QHostAddress::LocalHostIPv6)); //test dual -> v6 - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size()); QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); dgram = v6Sock.receiveDatagram(100); QVERIFY(dgram.isValid()); @@ -662,7 +662,7 @@ void tst_QUdpSocket::dualStack() } //test dual -> v4 - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size()); QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); dgram = v4Sock.receiveDatagram(100); QVERIFY(dgram.isValid()); @@ -701,19 +701,19 @@ void tst_QUdpSocket::dualStackAutoBinding() //test an autobound socket can send to both v4 and v6 addresses (v4 first) QUdpSocket dualSock; - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size()); QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); buffer.reserve(100); size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); + QCOMPARE((int)size, dualData.size()); buffer.resize(size); QCOMPARE(buffer, dualData); - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size()); QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); buffer.reserve(100); size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); + QCOMPARE((int)size, dualData.size()); buffer.resize(size); QCOMPARE(buffer, dualData); } @@ -722,19 +722,19 @@ void tst_QUdpSocket::dualStackAutoBinding() //test an autobound socket can send to both v4 and v6 addresses (v6 first) QUdpSocket dualSock; - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.size()); QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); buffer.reserve(100); size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); + QCOMPARE((int)size, dualData.size()); buffer.resize(size); QCOMPARE(buffer, dualData); - QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); + QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.size(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.size()); QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); buffer.reserve(100); size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); + QCOMPARE((int)size, dualData.size()); buffer.resize(size); QCOMPARE(buffer, dualData); } @@ -755,7 +755,7 @@ void tst_QUdpSocket::dualStackNoIPv4onV6only() QVERIFY(v6Sock.bind(QHostAddress(QHostAddress::AnyIPv6), 0)); //test v4 -> v6 (should not be received as this is a v6 only socket) - QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), v6Sock.localPort()), v4Data.length()); + QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.size(), QHostAddress(QHostAddress::LocalHost), v6Sock.localPort()), v4Data.size()); QVERIFY(!v6Sock.waitForReadyRead(1000)); } @@ -875,17 +875,17 @@ void tst_QUdpSocket::writeDatagram() #if defined (Q_OS_HPUX) QSKIP("HP-UX 11.11 on hai (PA-RISC 64) truncates too long datagrams."); #endif - QCOMPARE(bytesspy.count(), 0); - QCOMPARE(errorspy.count(), 1); + QCOMPARE(bytesspy.size(), 0); + QCOMPARE(errorspy.size(), 1); QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()), int(QUdpSocket::DatagramTooLargeError)); QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError); break; } - QCOMPARE(bytesspy.count(), 1); + QCOMPARE(bytesspy.size(), 1); QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()), qint64(i * 1024)); - QCOMPARE(errorspy.count(), 0); + QCOMPARE(errorspy.size(), 0); if (!server.waitForReadyRead(5000)) QSKIP(QString("UDP packet lost at size %1, unable to complete the test.").arg(i * 1024).toLatin1().data()); QCOMPARE(server.pendingDatagramSize(), qint64(i * 1024)); @@ -998,7 +998,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer() QVERIFY(sUdp.bind()); QCOMPARE(sUdp.writeDatagram("", 1, peerAddress, peerPort), qint64(1)); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(sReadyReadSpy.count(), 0); + QCOMPARE(sReadyReadSpy.size(), 0); } void tst_QUdpSocket::writeToNonExistingPeer_data() @@ -1041,8 +1041,8 @@ void tst_QUdpSocket::writeToNonExistingPeer() // the third one will succeed... QCOMPARE(sConnected.write("", 1), qint64(1)); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(sConnectedReadyReadSpy.count(), 0); - QCOMPARE(sConnectedErrorSpy.count(), 1); + QCOMPARE(sConnectedReadyReadSpy.size(), 0); + QCOMPARE(sConnectedErrorSpy.size(), 1); QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError)); // we should now get a read error @@ -1550,7 +1550,7 @@ void tst_QUdpSocket::echo() { QFETCH(bool, connect); QHostInfo info = QHostInfo::fromName(QtNetworkSettings::echoServerName()); - QVERIFY(info.addresses().count()); + QVERIFY(info.addresses().size()); QHostAddress remote = info.addresses().first(); QUdpSocket sock; @@ -1577,7 +1577,7 @@ void tst_QUdpSocket::echo() in = sock.read(sock.pendingDatagramSize()); } else { in.resize(sock.pendingDatagramSize()); - sock.readDatagram(in.data(), in.length(), &from, &port); + sock.readDatagram(in.data(), in.size(), &from, &port); } if (in==out) successes++; @@ -1647,21 +1647,21 @@ void tst_QUdpSocket::linkLocalIPv6() QSignalSpy spy(s, SIGNAL(readyRead())); QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); - QTRY_VERIFY(neutralReadSpy.count() > 0); //note may need to accept a firewall prompt + QTRY_VERIFY(neutralReadSpy.size() > 0); //note may need to accept a firewall prompt - QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2); + QNetworkDatagram dgram = neutral.receiveDatagram(testData.size() * 2); QVERIFY(dgram.isValid()); QCOMPARE(dgram.senderAddress(), s->localAddress()); QCOMPARE(dgram.senderPort(), int(s->localPort())); QCOMPARE(dgram.destinationAddress(), s->localAddress()); QCOMPARE(dgram.destinationPort(), int(neutral.localPort())); - QCOMPARE(dgram.data().length(), testData.length()); + QCOMPARE(dgram.data().size(), testData.size()); QCOMPARE(dgram.data(), testData); QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); - QTRY_VERIFY(spy.count() > 0); //note may need to accept a firewall prompt + QTRY_VERIFY(spy.size() > 0); //note may need to accept a firewall prompt - dgram = s->receiveDatagram(testData.length() * 2); + dgram = s->receiveDatagram(testData.size() * 2); QCOMPARE(dgram.data(), testData); //sockets bound to other interfaces shouldn't have received anything @@ -1728,11 +1728,11 @@ void tst_QUdpSocket::linkLocalIPv4() QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); QVERIFY2(neutral.waitForReadyRead(10000), QtNetworkSettings::msgSocketError(neutral).constData()); - QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2); + QNetworkDatagram dgram = neutral.receiveDatagram(testData.size() * 2); QVERIFY(dgram.isValid()); QCOMPARE(dgram.senderAddress(), s->localAddress()); QCOMPARE(dgram.senderPort(), int(s->localPort())); - QCOMPARE(dgram.data().length(), testData.length()); + QCOMPARE(dgram.data().size(), testData.size()); QCOMPARE(dgram.data(), testData); // Unlike for IPv6 with IPV6_PKTINFO, IPv4 has no standardized way of @@ -1751,7 +1751,7 @@ void tst_QUdpSocket::linkLocalIPv4() QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData()); - dgram = s->receiveDatagram(testData.length() * 2); + dgram = s->receiveDatagram(testData.size() * 2); QVERIFY(dgram.isValid()); QCOMPARE(dgram.data(), testData); @@ -1786,7 +1786,7 @@ void tst_QUdpSocket::readyRead() QTest::qWait(100); // make sure only one signal was emitted - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(receiver.hasPendingDatagrams()); #ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(receiver.bytesAvailable(), qint64(2)); @@ -1798,7 +1798,7 @@ void tst_QUdpSocket::readyRead() // no new signal should be emitted because we haven't read the first datagram yet QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(receiver.hasPendingDatagrams()); QVERIFY(receiver.bytesAvailable() >= 1); // most likely is 1, but it could be 1 + 2 in the future QCOMPARE(receiver.pendingDatagramSize(), qint64(2)); @@ -1810,7 +1810,7 @@ void tst_QUdpSocket::readyRead() // write a new datagram and ensure the signal is emitted now sender.writeDatagram("abc", makeNonAny(receiver.localAddress()), port); QTest::qWait(100); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(receiver.hasPendingDatagrams()); #ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(receiver.bytesAvailable(), qint64(3)); @@ -1890,7 +1890,7 @@ void tst_QUdpSocket::asyncReadDatagram() QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); delete m_asyncSender; delete m_asyncReceiver; diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 20a84b3077..3f8361a5c2 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -498,7 +498,7 @@ void tst_QSslCertificate::utf8SubjectNames() static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC"; // the following two tests should help find "\x"-literal encoding bugs in the test itself - QCOMPARE(cert.subjectInfo("O")[0].length(), QString::fromUtf8(o).length()); + QCOMPARE(cert.subjectInfo("O")[0].size(), QString::fromUtf8(o).size()); QCOMPARE (cert.subjectInfo("O")[0].toUtf8().toHex(), QByteArray(o).toHex()); QCOMPARE(cert.subjectInfo("O")[0], QString::fromUtf8(o)); @@ -946,8 +946,8 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489 void tst_QSslCertificate::blacklistedCertificates() { QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QSslCertificate::PatternSyntax::Wildcard); - QVERIFY(blacklistedCerts.count() > 0); - for (int a = 0; a < blacklistedCerts.count(); a++) { + QVERIFY(blacklistedCerts.size() > 0); + for (int a = 0; a < blacklistedCerts.size(); a++) { QVERIFY(blacklistedCerts.at(a).isBlacklisted()); } } @@ -989,7 +989,7 @@ void tst_QSslCertificate::multipleCommonNames() { QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - QVERIFY(certList.count() > 0); + QVERIFY(certList.size() > 0); QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName); QVERIFY(commonNames.contains(QString("www.example.com"))); @@ -1000,14 +1000,14 @@ void tst_QSslCertificate::subjectAndIssuerAttributes() { QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - QVERIFY(certList.count() > 0); + QVERIFY(certList.size() > 0); QList<QByteArray> attributes = certList[0].subjectInfoAttributes(); QVERIFY(attributes.contains(QByteArray("favouriteDrink"))); attributes.clear(); certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - QVERIFY(certList.count() > 0); + QVERIFY(certList.size() > 0); QByteArray shortName("1.3.6.1.4.1.311.60.2.1.3"); #if !defined(QT_NO_OPENSSL) && defined(SN_jurisdictionCountryName) @@ -1034,7 +1034,7 @@ void tst_QSslCertificate::verify() // Empty chain is unspecified error errors = QSslCertificate::verify(toVerify); - VERIFY_VERBOSE(errors.count() == 1); + VERIFY_VERBOSE(errors.size() == 1); VERIFY_VERBOSE(errors[0] == QSslError(QSslError::UnspecifiedError)); errors.clear(); @@ -1053,7 +1053,7 @@ void tst_QSslCertificate::verify() toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); errors = QSslCertificate::verify(toVerify); - VERIFY_VERBOSE(errors.count() == 0); + VERIFY_VERBOSE(errors.size() == 0); errors.clear(); // Test a blacklisted certificate @@ -1088,11 +1088,11 @@ void tst_QSslCertificate::verify() toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); errors = QSslCertificate::verify(toVerify); - VERIFY_VERBOSE(errors.count() == 0); + VERIFY_VERBOSE(errors.size() == 0); // Recheck the above with hostname validation errors = QSslCertificate::verify(toVerify, QLatin1String("example.com")); - VERIFY_VERBOSE(errors.count() == 0); + VERIFY_VERBOSE(errors.size() == 0); // Recheck the above with a bad hostname errors = QSslCertificate::verify(toVerify, QLatin1String("fail.example.com")); @@ -1117,11 +1117,11 @@ void tst_QSslCertificate::extensions() { QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - QVERIFY(certList.count() > 0); + QVERIFY(certList.size() > 0); QSslCertificate cert = certList[0]; QList<QSslCertificateExtension> extensions = cert.extensions(); - QCOMPARE(extensions.count(), 9); + QCOMPARE(extensions.size(), 9); int unknown_idx = -1; int authority_info_idx = -1; @@ -1129,7 +1129,7 @@ void tst_QSslCertificate::extensions() int subject_key_idx = -1; int auth_key_idx = -1; - for (int i=0; i < extensions.length(); ++i) { + for (int i=0; i < extensions.size(); ++i) { QSslCertificateExtension ext = extensions[i]; //qDebug() << i << ":" << ext.name() << ext.oid(); @@ -1215,16 +1215,16 @@ void tst_QSslCertificate::extensionsCritical() { QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - QVERIFY(certList.count() > 0); + QVERIFY(certList.size() > 0); QSslCertificate cert = certList[0]; QList<QSslCertificateExtension> extensions = cert.extensions(); - QCOMPARE(extensions.count(), 9); + QCOMPARE(extensions.size(), 9); int basic_constraints_idx = -1; int key_usage_idx = -1; - for (int i=0; i < extensions.length(); ++i) { + for (int i=0; i < extensions.size(); ++i) { QSslCertificateExtension ext = extensions[i]; if (ext.name() == QStringLiteral("basicConstraints")) diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 627b6cca98..12f29bf107 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -315,7 +315,7 @@ void tst_QSslKey::constructorHandle() passphrase = "1234"; BIO* bio = q_BIO_new(q_BIO_s_mem()); - q_BIO_write(bio, pem.constData(), pem.length()); + q_BIO_write(bio, pem.constData(), pem.size()); EVP_PKEY *origin = func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data())); Q_ASSERT(origin); q_EVP_PKEY_up_ref(origin); diff --git a/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp b/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp index 77a86ceac3..5170f2f8b7 100644 --- a/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp +++ b/tests/auto/network/ssl/qsslserver/tst_qsslserver.cpp @@ -142,15 +142,15 @@ void tst_QSslServer::testOneSuccessfulConnection() QVERIFY(server.startedEncryptionHandshakeSpy.isValid()); // Check that no connections has occurred - QCOMPARE(server.sslErrorsSpy.count(), 0); - QCOMPARE(server.peerVerifyErrorSpy.count(), 0); - QCOMPARE(server.errorOccurredSpy.count(), 0); - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), 0); - QCOMPARE(server.alertReceivedSpy.count(), 0); - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 0); + QCOMPARE(server.sslErrorsSpy.size(), 0); + QCOMPARE(server.peerVerifyErrorSpy.size(), 0); + QCOMPARE(server.errorOccurredSpy.size(), 0); + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), 0); + QCOMPARE(server.alertReceivedSpy.size(), 0); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 0); // Connect client QSslSocket client; @@ -187,15 +187,15 @@ void tst_QSslServer::testOneSuccessfulConnection() loop.exec(); // Check that one encrypted connection has occurred without error - QCOMPARE(server.sslErrorsSpy.count(), 0); - QCOMPARE(server.peerVerifyErrorSpy.count(), 0); - QCOMPARE(server.errorOccurredSpy.count(), 0); - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), 0); - QCOMPARE(server.alertReceivedSpy.count(), 0); - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.sslErrorsSpy.size(), 0); + QCOMPARE(server.peerVerifyErrorSpy.size(), 0); + QCOMPARE(server.errorOccurredSpy.size(), 0); + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), 0); + QCOMPARE(server.alertReceivedSpy.size(), 0); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); // Check client socket QVERIFY(client.isEncrypted()); @@ -224,16 +224,16 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByServer() loop.exec(); // Check that one encrypted connection has failed - QCOMPARE(server.sslErrorsSpy.count(), 1); - QCOMPARE(server.peerVerifyErrorSpy.count(), 1); - QCOMPARE(server.errorOccurredSpy.count(), 1); - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), + QCOMPARE(server.sslErrorsSpy.size(), 1); + QCOMPARE(server.peerVerifyErrorSpy.size(), 1); + QCOMPARE(server.errorOccurredSpy.size(), 1); + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), isTestingOpenSsl ? 1 : 0); // OpenSSL only signal - QCOMPARE(server.alertReceivedSpy.count(), 0); - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.alertReceivedSpy.size(), 0); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); // Type of certificate error to expect const auto certificateError = @@ -290,32 +290,32 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByClient() QTcpSocket *connection = server.server.nextPendingConnection(); if (connection == nullptr) { // Client disconnected before connection accepted by server - QCOMPARE(server.sslErrorsSpy.count(), 0); - QCOMPARE(server.peerVerifyErrorSpy.count(), 0); - QCOMPARE(server.errorOccurredSpy.count(), 1); // Client rejected first - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), 0); - QCOMPARE(server.alertReceivedSpy.count(), + QCOMPARE(server.sslErrorsSpy.size(), 0); + QCOMPARE(server.peerVerifyErrorSpy.size(), 0); + QCOMPARE(server.errorOccurredSpy.size(), 1); // Client rejected first + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), 0); + QCOMPARE(server.alertReceivedSpy.size(), isTestingOpenSsl ? 1 : 0); // OpenSSL only signal - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); const auto errrOccuredSpyError = qvariant_cast<QAbstractSocket::SocketError>( qAsConst(server.errorOccurredSpy).first()[1]); QCOMPARE(errrOccuredSpyError, socketError); } else { // Client disconnected after connection accepted by server - QCOMPARE(server.sslErrorsSpy.count(), 0); - QCOMPARE(server.peerVerifyErrorSpy.count(), 0); - QCOMPARE(server.errorOccurredSpy.count(), 0); // Server accepted first - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), 0); - QCOMPARE(server.alertReceivedSpy.count(), + QCOMPARE(server.sslErrorsSpy.size(), 0); + QCOMPARE(server.peerVerifyErrorSpy.size(), 0); + QCOMPARE(server.errorOccurredSpy.size(), 0); // Server accepted first + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), 0); + QCOMPARE(server.alertReceivedSpy.size(), isTestingOpenSsl ? 1 : 0); // OpenSSL only signal - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); QCOMPARE(connection->state(), QAbstractSocket::UnconnectedState); QCOMPARE(connection->error(), socketError); @@ -325,12 +325,12 @@ void tst_QSslServer::testSelfSignedCertificateRejectedByClient() } // Check that client has rejected server - QCOMPARE(clientConnectedSpy.count(), 1); - QCOMPARE(clientHostFoundSpy.count(), 1); - QCOMPARE(clientDisconnectedSpy.count(), 1); - QCOMPARE(clientConnectionEncryptedSpy.count(), 0); - QCOMPARE(clientSslErrorsSpy.count(), isTestingOpenSsl ? 0 : 1); - QCOMPARE(clientErrorOccurredSpy.count(), 1); + QCOMPARE(clientConnectedSpy.size(), 1); + QCOMPARE(clientHostFoundSpy.size(), 1); + QCOMPARE(clientDisconnectedSpy.size(), 1); + QCOMPARE(clientConnectionEncryptedSpy.size(), 0); + QCOMPARE(clientSslErrorsSpy.size(), isTestingOpenSsl ? 0 : 1); + QCOMPARE(clientErrorOccurredSpy.size(), 1); // Check client socket QVERIFY(!client.isEncrypted()); @@ -364,15 +364,15 @@ void tst_QSslServer::testHandshakeInterruptedOnError() loop.exec(); // Check that client certificate causes handshake interrupted signal to be emitted - QCOMPARE(server.sslErrorsSpy.count(), 0); - QCOMPARE(server.peerVerifyErrorSpy.count(), 0); - QCOMPARE(server.errorOccurredSpy.count(), 1); - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 0); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 0); - QCOMPARE(server.alertSentSpy.count(), 1); - QCOMPARE(server.alertReceivedSpy.count(), 0); - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 1); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.sslErrorsSpy.size(), 0); + QCOMPARE(server.peerVerifyErrorSpy.size(), 0); + QCOMPARE(server.errorOccurredSpy.size(), 1); + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 0); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 0); + QCOMPARE(server.alertSentSpy.size(), 1); + QCOMPARE(server.alertReceivedSpy.size(), 0); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 1); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); } void tst_QSslServer::testPreSharedKeyAuthenticationRequired() @@ -422,15 +422,15 @@ void tst_QSslServer::testPreSharedKeyAuthenticationRequired() loop.exec(); // Check that server is connected - QCOMPARE(server.sslErrorsSpy.count(), 1); - QCOMPARE(server.peerVerifyErrorSpy.count(), 1); - QCOMPARE(server.errorOccurredSpy.count(), 0); - QCOMPARE(server.pendingConnectionAvailableSpy.count(), 1); - QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.count(), 1); - QCOMPARE(server.alertSentSpy.count(), 0); - QCOMPARE(server.alertReceivedSpy.count(), 0); - QCOMPARE(server.handshakeInterruptedOnErrorSpy.count(), 0); - QCOMPARE(server.startedEncryptionHandshakeSpy.count(), 1); + QCOMPARE(server.sslErrorsSpy.size(), 1); + QCOMPARE(server.peerVerifyErrorSpy.size(), 1); + QCOMPARE(server.errorOccurredSpy.size(), 0); + QCOMPARE(server.pendingConnectionAvailableSpy.size(), 1); + QCOMPARE(server.preSharedKeyAuthenticationRequiredSpy.size(), 1); + QCOMPARE(server.alertSentSpy.size(), 0); + QCOMPARE(server.alertReceivedSpy.size(), 0); + QCOMPARE(server.handshakeInterruptedOnErrorSpy.size(), 0); + QCOMPARE(server.startedEncryptionHandshakeSpy.size(), 1); // Check client socket QVERIFY(client.isEncrypted()); @@ -457,7 +457,7 @@ void tst_QSslServer::plaintextClient() socket.write("Hello World!"); socket.waitForBytesWritten(); // ... and quickly get disconnected: - QTRY_COMPARE_GT(socketDisconnectedSpy.count(), 0); + QTRY_COMPARE_GT(socketDisconnectedSpy.size(), 0); QCOMPARE(socket.state(), QAbstractSocket::SocketState::UnconnectedState); } diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 81ba81fa40..cc81f41c67 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -836,30 +836,30 @@ void tst_QSslSocket::simpleConnect() // Entered connecting state QCOMPARE(socket.state(), QAbstractSocket::ConnectingState); - QCOMPARE(connectedSpy.count(), 0); - QCOMPARE(hostFoundSpy.count(), 1); - QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.size(), 0); + QCOMPARE(hostFoundSpy.size(), 1); + QCOMPARE(disconnectedSpy.size(), 0); enterLoop(10); // Entered connected state QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectedSpy.count(), 1); - QCOMPARE(hostFoundSpy.count(), 1); - QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.size(), 1); + QCOMPARE(hostFoundSpy.size(), 1); + QCOMPARE(disconnectedSpy.size(), 0); // Enter encrypted mode socket.startClientEncryption(); QCOMPARE(socket.mode(), QSslSocket::SslClientMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectionEncryptedSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 0); + QCOMPARE(connectionEncryptedSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); // Starting handshake enterLoop(10); - QCOMPARE(sslErrorsSpy.count(), 1); - QCOMPARE(connectionEncryptedSpy.count(), 0); + QCOMPARE(sslErrorsSpy.size(), 1); + QCOMPARE(connectionEncryptedSpy.size(), 0); QVERIFY(!socket.isEncrypted()); QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); } @@ -897,10 +897,10 @@ void tst_QSslSocket::simpleConnectWithIgnore() enterLoop(10); // Done; encryption should be enabled. - QCOMPARE(sslErrorsSpy.count(), 1); + QCOMPARE(sslErrorsSpy.size(), 1); QVERIFY(socket.isEncrypted()); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); - QCOMPARE(encryptedSpy.count(), 1); + QCOMPARE(encryptedSpy.size(), 1); // Wait for incoming data if (!socket.canReadLine()) @@ -1019,7 +1019,7 @@ void tst_QSslSocket::ciphers() QString ciphersAsString; const auto &supported = sslConfig.supportedCiphers(); for (const auto &cipher : supported) { - if (cipher.isNull() || !cipher.name().length()) + if (cipher.isNull() || !cipher.name().size()) continue; if (ciphers.size() > 0) ciphersAsString += QStringLiteral(":"); @@ -1237,7 +1237,7 @@ void tst_QSslSocket::peerCertificateChain() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(httpServerCertChainPath()); - QCOMPARE(caCertificates.count(), 1); + QCOMPARE(caCertificates.size(), 1); auto config = socket->sslConfiguration(); config.addCaCertificates(caCertificates); socket->setSslConfiguration(config); @@ -1254,7 +1254,7 @@ void tst_QSslSocket::peerCertificateChain() QSKIP("Skipping flaky test - See QTBUG-29941"); QList<QSslCertificate> certChain = socket->peerCertificateChain(); - QVERIFY(certChain.count() > 0); + QVERIFY(certChain.size() > 0); QCOMPARE(certChain.first(), socket->peerCertificate()); socket->disconnectFromHost(); @@ -2829,7 +2829,7 @@ void tst_QSslSocket::closeWhileEmittingSocketError() QTestEventLoop::instance().enterLoopMSecs(1000); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(socketErrorSpy.count(), 1); + QCOMPARE(socketErrorSpy.size(), 1); } #endif // Feature 'openssl'. @@ -2926,7 +2926,7 @@ void tst_QSslSocket::ignoreSslErrorsList() bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0); if (socket.waitForEncrypted(10000) != expectEncryptionSuccess) QSKIP("Skipping flaky test - See QTBUG-29941"); - QCOMPARE(sslErrorsSpy.count(), expectedSslErrorSignalCount); + QCOMPARE(sslErrorsSpy.size(), expectedSslErrorSignalCount); } void tst_QSslSocket::ignoreSslErrorsListWithSlot_data() @@ -3086,7 +3086,7 @@ void tst_QSslSocket::blacklistedCertificates() connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop())); enterLoop(1); QList<QSslError> sslErrors = receiver->sslHandshakeErrors(); - QVERIFY(sslErrors.count() > 0); + QVERIFY(sslErrors.size() > 0); // there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted); } @@ -3170,9 +3170,9 @@ void tst_QSslSocket::resume() QFETCH_GLOBAL(bool, setProxy); if (setProxy && QTestEventLoop::instance().timeout()) QSKIP("Skipping flaky test - See QTBUG-29941"); - QCOMPARE(sslErrorSpy.count(), 1); - QCOMPARE(errorSpy.count(), 0); - QCOMPARE(encryptedSpy.count(), 0); + QCOMPARE(sslErrorSpy.size(), 1); + QCOMPARE(errorSpy.size(), 0); + QCOMPARE(encryptedSpy.size(), 0); QVERIFY(!socket.isEncrypted()); if (ignoreErrorsAfterPause) { if (errorsToIgnore.empty()) @@ -3184,15 +3184,15 @@ void tst_QSslSocket::resume() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); // quit by encrypted() or error() signal if (expectSuccess) { - QCOMPARE(encryptedSpy.count(), 1); + QCOMPARE(encryptedSpy.size(), 1); QVERIFY(socket.isEncrypted()); - QCOMPARE(errorSpy.count(), 0); + QCOMPARE(errorSpy.size(), 0); socket.disconnectFromHost(); QVERIFY(socket.waitForDisconnected(10000)); } else { - QCOMPARE(encryptedSpy.count(), 0); + QCOMPARE(encryptedSpy.size(), 0); QVERIFY(!socket.isEncrypted()); - QCOMPARE(errorSpy.count(), 1); + QCOMPARE(errorSpy.size(), 1); QCOMPARE(socket.error(), QAbstractSocket::SslHandshakeFailedError); } } @@ -3379,17 +3379,17 @@ void tst_QSslSocket::qtbug18498_peek2() bigblock.fill('#', QIODEVICE_BUFFERSIZE + 1024); QVERIFY(client->write(QByteArray("head"))); QVERIFY(client->write(bigblock)); - QTRY_COMPARE(server->bytesAvailable(), bigblock.length() + 4); + QTRY_COMPARE(server->bytesAvailable(), bigblock.size() + 4); QCOMPARE(server->read(4), QByteArray("head")); - QCOMPARE(server->peek(bigblock.length()), bigblock); - b.reserve(bigblock.length()); - b.resize(server->peek(b.data(), bigblock.length())); + QCOMPARE(server->peek(bigblock.size()), bigblock); + b.reserve(bigblock.size()); + b.resize(server->peek(b.data(), bigblock.size())); QCOMPARE(b, bigblock); //check oversized peek - QCOMPARE(server->peek(bigblock.length() * 3), bigblock); - b.reserve(bigblock.length() * 3); - b.resize(server->peek(b.data(), bigblock.length() * 3)); + QCOMPARE(server->peek(bigblock.size() * 3), bigblock); + b.reserve(bigblock.size() * 3); + b.resize(server->peek(b.data(), bigblock.size() * 3)); QCOMPARE(b, bigblock); QCOMPARE(server->readAll(), bigblock); @@ -3725,7 +3725,7 @@ void tst_QSslSocket::verifyClientCertificate() } else { QCOMPARE(server.socket->peerCertificate(), clientCerts.first()); if (isTestingSchannel) { - if (clientCerts.count() == 1 && server.socket->peerCertificateChain().count() == 2) { + if (clientCerts.size() == 1 && server.socket->peerCertificateChain().size() == 2) { QEXPECT_FAIL("", "Schannel includes the entire chain, not just the leaf and intermediates", Continue); @@ -4085,14 +4085,14 @@ void tst_QSslSocket::simplePskConnect() case PskConnectWrongCredentials: // provide totally wrong credentials - provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.length() - 1)); - provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.length() - 1)); + provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.size() - 1)); + provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.size() - 1)); connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*))); break; case PskConnectWrongIdentity: // right PSK, wrong identity - provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.length() - 1)); + provider.setIdentity(PSK_CLIENT_IDENTITY.left(PSK_CLIENT_IDENTITY.size() - 1)); provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY); connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*))); break; @@ -4100,7 +4100,7 @@ void tst_QSslSocket::simplePskConnect() case PskConnectWrongPreSharedKey: // right identity, wrong PSK provider.setIdentity(PSK_CLIENT_IDENTITY); - provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.length() - 1)); + provider.setPreSharedKey(PSK_CLIENT_PRESHAREDKEY.left(PSK_CLIENT_PRESHAREDKEY.size() - 1)); connect(&socket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), &provider, SLOT(providePsk(QSslPreSharedKeyAuthenticator*))); break; @@ -4152,32 +4152,32 @@ void tst_QSslSocket::simplePskConnect() // Entered connecting state QCOMPARE(socket.state(), QAbstractSocket::ConnectingState); - QCOMPARE(connectedSpy.count(), 0); - QCOMPARE(hostFoundSpy.count(), 1); - QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.size(), 0); + QCOMPARE(hostFoundSpy.size(), 1); + QCOMPARE(disconnectedSpy.size(), 0); enterLoop(10); // Entered connected state QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectedSpy.count(), 1); - QCOMPARE(hostFoundSpy.count(), 1); - QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.size(), 1); + QCOMPARE(hostFoundSpy.size(), 1); + QCOMPARE(disconnectedSpy.size(), 0); // Enter encrypted mode socket.startClientEncryption(); QCOMPARE(socket.mode(), QSslSocket::SslClientMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectionEncryptedSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 0); - QCOMPARE(peerVerifyErrorSpy.count(), 0); + QCOMPARE(connectionEncryptedSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); + QCOMPARE(peerVerifyErrorSpy.size(), 0); // Start handshake. enterLoop(10); // We must get the PSK signal in all cases - QCOMPARE(pskAuthenticationRequiredSpy.count(), 1); + QCOMPARE(pskAuthenticationRequiredSpy.size(), 1); switch (pskTestType) { case PskConnectDoNotHandlePsk: @@ -4186,40 +4186,40 @@ void tst_QSslSocket::simplePskConnect() case PskConnectWrongIdentity: case PskConnectWrongPreSharedKey: // Handshake failure - QCOMPARE(socketErrorsSpy.count(), 1); + QCOMPARE(socketErrorsSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(socketErrorsSpy.at(0).at(0)), QAbstractSocket::SslHandshakeFailedError); - QCOMPARE(sslErrorsSpy.count(), 0); - QCOMPARE(peerVerifyErrorSpy.count(), 0); - QCOMPARE(connectionEncryptedSpy.count(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); + QCOMPARE(peerVerifyErrorSpy.size(), 0); + QCOMPARE(connectionEncryptedSpy.size(), 0); QVERIFY(!socket.isEncrypted()); break; case PskConnectRightCredentialsPeerVerifyFailure: // Peer verification failure - QCOMPARE(socketErrorsSpy.count(), 1); + QCOMPARE(socketErrorsSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractSocket::SocketError>(socketErrorsSpy.at(0).at(0)), QAbstractSocket::SslHandshakeFailedError); - QCOMPARE(sslErrorsSpy.count(), 1); - QCOMPARE(peerVerifyErrorSpy.count(), 1); - QCOMPARE(connectionEncryptedSpy.count(), 0); + QCOMPARE(sslErrorsSpy.size(), 1); + QCOMPARE(peerVerifyErrorSpy.size(), 1); + QCOMPARE(connectionEncryptedSpy.size(), 0); QVERIFY(!socket.isEncrypted()); break; case PskConnectRightCredentialsVerifyPeer: // Peer verification failure, but ignore it and keep connecting - QCOMPARE(socketErrorsSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 1); - QCOMPARE(peerVerifyErrorSpy.count(), 1); - QCOMPARE(connectionEncryptedSpy.count(), 1); + QCOMPARE(socketErrorsSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 1); + QCOMPARE(peerVerifyErrorSpy.size(), 1); + QCOMPARE(connectionEncryptedSpy.size(), 1); QVERIFY(socket.isEncrypted()); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); break; case PskConnectRightCredentialsDoNotVerifyPeer: // No peer verification => no failure - QCOMPARE(socketErrorsSpy.count(), 0); - QCOMPARE(sslErrorsSpy.count(), 0); - QCOMPARE(peerVerifyErrorSpy.count(), 0); - QCOMPARE(connectionEncryptedSpy.count(), 1); + QCOMPARE(socketErrorsSpy.size(), 0); + QCOMPARE(sslErrorsSpy.size(), 0); + QCOMPARE(peerVerifyErrorSpy.size(), 0); + QCOMPARE(connectionEncryptedSpy.size(), 1); QVERIFY(socket.isEncrypted()); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); break; @@ -4260,7 +4260,7 @@ void tst_QSslSocket::simplePskConnect() } QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); - QCOMPARE(disconnectedSpy.count(), 1); + QCOMPARE(disconnectedSpy.size(), 1); } void tst_QSslSocket::ephemeralServerKey_data() @@ -4293,7 +4293,7 @@ void tst_QSslSocket::ephemeralServerKey() client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); spy.wait(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(server.config.ephemeralServerKey().isNull()); QCOMPARE(client->sslConfiguration().ephemeralServerKey().isNull(), emptyKey); } @@ -4356,22 +4356,22 @@ void tst_QSslSocket::pskServer() QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QCOMPARE(socket.mode(), QSslSocket::UnencryptedMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectedSpy.count(), 1); - QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.size(), 1); + QCOMPARE(disconnectedSpy.size(), 0); // Enter encrypted mode socket.startClientEncryption(); QCOMPARE(socket.mode(), QSslSocket::SslClientMode); QVERIFY(!socket.isEncrypted()); - QCOMPARE(connectionEncryptedSpy.count(), 0); + QCOMPARE(connectionEncryptedSpy.size(), 0); // Start handshake. enterLoop(10); // We must get the PSK signal in all cases - QCOMPARE(pskAuthenticationRequiredSpy.count(), 1); + QCOMPARE(pskAuthenticationRequiredSpy.size(), 1); - QCOMPARE(connectionEncryptedSpy.count(), 1); + QCOMPARE(connectionEncryptedSpy.size(), 1); QVERIFY(socket.isEncrypted()); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); @@ -4384,7 +4384,7 @@ void tst_QSslSocket::pskServer() enterLoop(10); QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState); - QCOMPARE(disconnectedSpy.count(), 1); + QCOMPARE(disconnectedSpy.size(), 1); } void tst_QSslSocket::signatureAlgorithm_data() @@ -4537,7 +4537,7 @@ void tst_QSslSocket::forwardReadChannelFinished() &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); enterLoop(10); - QVERIFY(readChannelFinishedSpy.count()); + QVERIFY(readChannelFinishedSpy.size()); } #endif // QT_CONFIG(openssl) @@ -4724,8 +4724,8 @@ void tst_QSslSocket::alertMissingCertificate() runner.enterLoopMSecs(10000); } - QVERIFY(serverSpy.count() > 0); - QVERIFY(clientSpy.count() > 0); + QVERIFY(serverSpy.size() > 0); + QVERIFY(clientSpy.size() > 0); QVERIFY(server.socket && !server.socket->isEncrypted()); QVERIFY(!clientSocket.isEncrypted()); } @@ -4778,9 +4778,9 @@ void tst_QSslSocket::alertInvalidCertificate() runner.enterLoopMSecs(1000); - QVERIFY(serverSpy.count() > 0); - QVERIFY(clientSpy.count() > 0); - QVERIFY(interruptedSpy.count() > 0); + QVERIFY(serverSpy.size() > 0); + QVERIFY(clientSpy.size() > 0); + QVERIFY(interruptedSpy.size() > 0); QVERIFY(server.socket && !server.socket->isEncrypted()); QVERIFY(!clientSocket.isEncrypted()); } @@ -4907,14 +4907,14 @@ void tst_QSslSocket::selfSignedCertificates() runner.enterLoopMSecs(1000); if (clientKnown) { - QCOMPARE(serverSpy.count(), 0); - QCOMPARE(clientSpy.count(), 0); + QCOMPARE(serverSpy.size(), 0); + QCOMPARE(clientSpy.size(), 0); QVERIFY(server.socket && server.socket->isEncrypted()); QVERIFY(clientSocket.isEncrypted()); } else { - QVERIFY(serverSpy.count() > 0); + QVERIFY(serverSpy.size() > 0); QEXPECT_FAIL("", "Failing to trigger signal, QTBUG-81661", Continue); - QVERIFY(clientSpy.count() > 0); + QVERIFY(clientSpy.size() > 0); QVERIFY(server.socket && !server.socket->isEncrypted()); QVERIFY(!clientSocket.isEncrypted()); } @@ -5045,15 +5045,15 @@ void tst_QSslSocket::pskHandshake() runner.enterLoopMSecs(1000); if (pskRight) { - QCOMPARE(serverSpy.count(), 0); - QCOMPARE(clientSpy.count(), 0); + QCOMPARE(serverSpy.size(), 0); + QCOMPARE(clientSpy.size(), 0); QVERIFY(server.socket && server.socket->isEncrypted()); QVERIFY(clientSocket.isEncrypted()); } else { - QVERIFY(serverSpy.count() > 0); + QVERIFY(serverSpy.size() > 0); QCOMPARE(serverSpy.first().at(0).toInt(), static_cast<int>(QSsl::AlertLevel::Fatal)); QCOMPARE(serverSpy.first().at(1).toInt(), static_cast<int>(QSsl::AlertType::BadRecordMac)); - QVERIFY(clientSpy.count() > 0); + QVERIFY(clientSpy.size() > 0); QCOMPARE(clientSpy.first().at(0).toInt(), static_cast<int>(QSsl::AlertLevel::Fatal)); QCOMPARE(clientSpy.first().at(1).toInt(), static_cast<int>(QSsl::AlertType::BadRecordMac)); QVERIFY(server.socket && !server.socket->isEncrypted()); diff --git a/tests/auto/network/ssl/shared/qopenssl_symbols.h b/tests/auto/network/ssl/shared/qopenssl_symbols.h index 13cacc5317..dff5bc8163 100644 --- a/tests/auto/network/ssl/shared/qopenssl_symbols.h +++ b/tests/auto/network/ssl/shared/qopenssl_symbols.h @@ -405,7 +405,7 @@ struct LibGreaterThan { const auto lhsparts = lhs.split(QLatin1Char('.')); const auto rhsparts = rhs.split(QLatin1Char('.')); - Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1); + Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1); // note: checking rhs < lhs, the same as lhs > rhs return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(), diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index b80f676d2f..80d1164413 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -584,7 +584,7 @@ void tst_Gestures::conflictingGestures() QCOMPARE(child->gestureOverrideEventsReceived, 1); QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount); - QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount); + QCOMPARE(child->events.all.size(), TotalGestureEventsCount + ContinuousGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); @@ -1409,13 +1409,13 @@ void tst_Gestures::ungrabGesture() // a method on QWidget // sending an event will cause the QGesture objects to be instantiated for the widgets sendCustomGesture(&event, b); - QCOMPARE(a->gestures.count(), 1); + QCOMPARE(a->gestures.size(), 1); QPointer<QGesture> customGestureA; customGestureA = *(a->gestures.begin()); QVERIFY(!customGestureA.isNull()); QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); - QCOMPARE(b->gestures.count(), 1); + QCOMPARE(b->gestures.size(), 1); QPointer<QGesture> customGestureB; customGestureB = *(b->gestures.begin()); QVERIFY(!customGestureB.isNull()); @@ -1426,7 +1426,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget // sending an event will cause the QGesture objects to be instantiated for the widget sendCustomGesture(&event, a); - QCOMPARE(a->gestures.count(), 1); + QCOMPARE(a->gestures.size(), 1); customGestureA = *(a->gestures.begin()); QVERIFY(!customGestureA.isNull()); QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); @@ -1471,7 +1471,7 @@ void tst_Gestures::autoCancelGestures() { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); - if (ge->gestures().count() != 1) + if (ge->gestures().size() != 1) ++badGestureEvents; // event should contain exactly one gesture ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } @@ -1504,15 +1504,15 @@ void tst_Gestures::autoCancelGestures() CustomEvent event; event.serial = CustomGesture::SerialStartedThreshold; QApplication::sendEvent(child, &event); - QCOMPARE(child->events.all.count(), 2); - QCOMPARE(child->events.started.count(), 1); - QCOMPARE(child->events.canceled.count(), 1); - QCOMPARE(parent.events.all.count(), 1); + QCOMPARE(child->events.all.size(), 2); + QCOMPARE(child->events.started.size(), 1); + QCOMPARE(child->events.canceled.size(), 1); + QCOMPARE(parent.events.all.size(), 1); // clean up, make the parent gesture finish event.serial = CustomGesture::SerialFinishedThreshold; QApplication::sendEvent(child, &event); - QCOMPARE(parent.events.all.count(), 2); + QCOMPARE(parent.events.all.size(), 2); QCOMPARE(parent.badGestureEvents, 0); } @@ -1526,7 +1526,7 @@ void tst_Gestures::autoCancelGestures2() { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); - if (ge->gestures().count() != 1) + if (ge->gestures().size() != 1) ++badGestureEvents; // event should contain exactly one gesture ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } @@ -1561,15 +1561,15 @@ void tst_Gestures::autoCancelGestures2() event.hasHotSpot = true; event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view); scene.sendEvent(child, &event); - QCOMPARE(parent->events.all.count(), 1); - QCOMPARE(child->events.started.count(), 1); - QCOMPARE(child->events.canceled.count(), 1); - QCOMPARE(child->events.all.count(), 2); + QCOMPARE(parent->events.all.size(), 1); + QCOMPARE(child->events.started.size(), 1); + QCOMPARE(child->events.canceled.size(), 1); + QCOMPARE(child->events.all.size(), 2); // clean up, make the parent gesture finish event.serial = CustomGesture::SerialFinishedThreshold; scene.sendEvent(child, &event); - QCOMPARE(parent->events.all.count(), 2); + QCOMPARE(parent->events.all.size(), 2); QCOMPARE(parent->badGestureEvents, 0); } diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 824f26aeaa..16b7d33097 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -105,8 +105,8 @@ static QString prettyByteArray(const QByteArray &array) { // any control chars? QString result; - result.reserve(array.length() + array.length() / 3); - for (int i = 0; i < array.length(); ++i) { + result.reserve(array.size() + array.size() / 3); + for (int i = 0; i < array.size(); ++i) { char c = array.at(i); switch (c) { case '\n': @@ -208,11 +208,11 @@ static void netChat(int port, const QList<Chat> &chat) switch (it->type) { case Chat::Expect: { qDebug() << i << "Expecting" << prettyByteArray(it->data); - if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS)) - QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length())); + if (!doSocketRead(&socket, it->data.size(), 3 * defaultReadTimeoutMS)) + QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size())); // pop that many bytes off the socket - QByteArray received = socket.read(it->data.length()); + QByteArray received = socket.read(it->data.size()); // is it what we expected? QVERIFY2(received == it->data, @@ -226,8 +226,8 @@ static void netChat(int port, const QList<Chat> &chat) qDebug() << i << "Discarding until" << prettyByteArray(it->data); while (true) { // scan the buffer until we have our string - if (!doSocketRead(&socket, it->data.length())) - QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length())); + if (!doSocketRead(&socket, it->data.size())) + QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size())); QByteArray buffer; buffer.resize(socket.bytesAvailable()); @@ -239,7 +239,7 @@ static void netChat(int port, const QList<Chat> &chat) continue; } - buffer = socket.read(pos + it->data.length()); + buffer = socket.read(pos + it->data.size()); qDebug() << i << "Discarded" << prettyByteArray(buffer); break; } diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h index 2e93f24fd3..b0382ef60a 100644 --- a/tests/auto/other/qaccessibility/accessiblewidgets.h +++ b/tests/auto/other/qaccessibility/accessiblewidgets.h @@ -116,7 +116,7 @@ public: int cursorPosition() const override { return textWidget()->cursorPosition; } void setCursorPosition(int position) override { textWidget()->cursorPosition = position; } QString text(int startOffset, int endOffset) const override { return textWidget()->text.mid(startOffset, endOffset); } - int characterCount() const override { return textWidget()->text.length(); } + int characterCount() const override { return textWidget()->text.size(); } QRect characterRect(int) const override { return QRect(); } int offsetAtPoint(const QPoint &) const override { return 0; } void scrollToSubstring(int, int) override {} diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 87c6810365..60a8dde623 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -294,9 +294,9 @@ void tst_QAccessibility::cleanup() { const EventList list = QTestAccessibility::events(); if (!list.isEmpty()) { - qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.count()), + qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.size()), QString(QTest::currentTestFunction()).toLatin1().constData()); - for (int i = 0; i < list.count(); ++i) + for (int i = 0; i < list.size(); ++i) qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i)->object(), qAccessibleEventString(list.at(i)->type()), list.at(i)->child()); } @@ -782,7 +782,7 @@ void tst_QAccessibility::textAttributes() QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit); QAccessibleTextInterface *textInterface=interface->textInterface(); QVERIFY(textInterface); - QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length()); + QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().size()); int startOffset = -1; int endOffset = -1; @@ -1944,7 +1944,7 @@ void tst_QAccessibility::mdiAreaTest() mdiArea.addSubWindow(new QWidget, Qt::Dialog)->show(); QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList(); - QCOMPARE(subWindows.count(), subWindowCount); + QCOMPARE(subWindows.size(), subWindowCount); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mdiArea); QVERIFY(interface); @@ -1982,7 +1982,7 @@ void tst_QAccessibility::mdiSubWindowTest() } QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList(); - QCOMPARE(subWindows.count(), subWindowCount); + QCOMPARE(subWindows.size(), subWindowCount); QMdiSubWindow *testWindow = subWindows.at(3); QVERIFY(testWindow); @@ -2106,10 +2106,10 @@ void tst_QAccessibility::lineEditTest() QCOMPARE(iface->text(QAccessible::Value), QString()); le->setEchoMode(QLineEdit::Password); QVERIFY(iface->state().passwordEdit); - QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*'))); + QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*'))); le->setEchoMode(QLineEdit::PasswordEchoOnEdit); QVERIFY(iface->state().passwordEdit); - QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*'))); + QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*'))); le->setEchoMode(QLineEdit::Normal); QVERIFY(!(iface->state().passwordEdit)); QCOMPARE(iface->text(QAccessible::Value), secret); @@ -2201,7 +2201,7 @@ void tst_QAccessibility::lineEditTest() QCOMPARE(textIface->textAtOffset(5, QAccessible::ParagraphBoundary,&start,&end), cite); QCOMPARE(start, 0); - QCOMPARE(end, cite.length()); + QCOMPARE(end, cite.size()); QCOMPARE(textIface->textAtOffset(5, QAccessible::LineBoundary,&start,&end), cite); QCOMPARE(textIface->textAtOffset(5, QAccessible::NoBoundary,&start,&end), cite); @@ -2245,8 +2245,8 @@ void tst_QAccessibility::lineEditTest() QVERIFY_EVENT(&sel); lineEdit->selectAll(); - sel.setSelection(0, lineEdit->text().length()); - sel.setCursorPosition(lineEdit->text().length()); + sel.setSelection(0, lineEdit->text().size()); + sel.setCursorPosition(lineEdit->text().size()); QVERIFY_EVENT(&sel); lineEdit->setSelection(10, -4); @@ -2602,7 +2602,7 @@ void tst_QAccessibility::dialogButtonBoxTest() std::sort(buttons.begin(), buttons.end(), accessibleInterfaceLeftOf); - for (int i = 0; i < buttons.count(); ++i) + for (int i = 0; i < buttons.size(); ++i) actualOrder << buttons.at(i)->text(QAccessible::Name); QStringList expectedOrder; @@ -2654,7 +2654,7 @@ void tst_QAccessibility::dialogButtonBoxTest() std::sort(buttons.begin(), buttons.end(), accessibleInterfaceAbove); - for (int i = 0; i < buttons.count(); ++i) + for (int i = 0; i < buttons.size(); ++i) actualOrder << buttons.at(i)->text(QAccessible::Name); QStringList expectedOrder; @@ -3716,7 +3716,7 @@ void tst_QAccessibility::labelTest() QCOMPARE(acc_label->state().readOnly, true); QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = acc_label->relations(); - QCOMPARE(rels.count(), 1); + QCOMPARE(rels.size(), 1); QAccessibleInterface *iface = rels.first().first; QAccessible::Relation rel = rels.first().second; @@ -4173,7 +4173,7 @@ void tst_QAccessibility::focusChild() spy.clear(); tableView->setCurrentCell(2, 1); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QAccessibleInterface *child = iface->focusChild(); QVERIFY(child); @@ -4181,7 +4181,7 @@ void tst_QAccessibility::focusChild() spy.clear(); tableView->setCurrentCell(1, 2); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); child = iface->focusChild(); QVERIFY(child); @@ -4233,7 +4233,7 @@ void tst_QAccessibility::focusChild() spy.clear(); treeView->setCurrentItem(item2); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QAccessibleInterface *child = iface->focusChild(); QVERIFY(child); @@ -4241,7 +4241,7 @@ void tst_QAccessibility::focusChild() spy.clear(); treeView->setCurrentItem(item3); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); child = iface->focusChild(); QVERIFY(child); diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index 1b944bf1b6..a164851886 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -84,7 +84,7 @@ void tst_QComplexText::bidiReorderString() if (si.analysis.bidiLevel % 2) { // reverse sub QChar *a = sub.data(); - QChar *b = a + sub.length() - 1; + QChar *b = a + sub.size() - 1; while (a < b) { QChar tmp = *a; *a = *b; @@ -93,7 +93,7 @@ void tst_QComplexText::bidiReorderString() --b; } a = (QChar *)sub.unicode(); - b = a + sub.length(); + b = a + sub.size(); while (a<b) { *a = a->mirroredChar(); ++a; @@ -315,7 +315,7 @@ static void testBidiString(const QString &data, int paragraphDirection, if (si.analysis.bidiLevel % 2) { // reverse sub QChar *a = sub.data(); - QChar *b = a + sub.length() - 1; + QChar *b = a + sub.size() - 1; while (a < b) { QChar tmp = *a; *a = *b; @@ -324,7 +324,7 @@ static void testBidiString(const QString &data, int paragraphDirection, --b; } a = (QChar *)sub.unicode(); - b = a + sub.length(); + b = a + sub.size(); // while (a<b) { // *a = a->mirroredChar(); // ++a; diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp index e70d132ea7..3541576bb8 100644 --- a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp +++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp @@ -35,20 +35,20 @@ void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop() qApp->processEvents(QEventLoop::AllEvents, 100); // we mustn't have read anything in the event loop - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // ensure the process hasn't died QVERIFY(!process.waitForFinished(250)); // we mustn't have read anything during waitForFinished either - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // release the child for the second write process.write("\n"); QVERIFY(process.waitForFinished(5000)); QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit)); QCOMPARE(process.exitCode(), 0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(process.readAll().trimmed(), msg); #endif } diff --git a/tests/auto/sql/kernel/qsql/tst_qsql.cpp b/tests/auto/sql/kernel/qsql/tst_qsql.cpp index 1d6b271f44..55cbfad421 100644 --- a/tests/auto/sql/kernel/qsql/tst_qsql.cpp +++ b/tests/auto/sql/kernel/qsql/tst_qsql.cpp @@ -125,10 +125,10 @@ void tst_QSql::open() QVERIFY(dbs.open()); if (count == -1) // first iteration: see how many dbs are open - count = (int) dbs.dbNames.count(); + count = (int) dbs.dbNames.size(); else // next iterations: make sure all are opened again - QCOMPARE(count, (int)dbs.dbNames.count()); + QCOMPARE(count, (int)dbs.dbNames.size()); dbs.close(); } } diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index b77b4fd47a..a3408e38d7 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -125,7 +125,7 @@ public: QTest::addColumn<QString>( "dbName" ); int count = 0; - for ( int i = 0; i < dbNames.count(); ++i ) { + for ( int i = 0; i < dbNames.size(); ++i ) { QSqlDatabase db = QSqlDatabase::database( dbNames.at( i ) ); if ( !db.isValid() ) @@ -146,7 +146,7 @@ public: QTest::addColumn<int>("submitpolicy_i"); int count = 0; - for ( int i = 0; i < dbNames.count(); ++i ) { + for ( int i = 0; i < dbNames.size(); ++i ) { QSqlDatabase db = QSqlDatabase::database( dbNames.at( i ) ); if ( !db.isValid() ) diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 2e143aff21..c1d8faa418 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -210,7 +210,7 @@ struct FieldDef { rt.replace(QRegularExpression("\\s"), QString("_")); int i = rt.indexOf(QLatin1Char('(')); if (i == -1) - i = rt.length(); + i = rt.size(); if (i > 20) i = 20; return "t_" + rt.left(i); @@ -1904,13 +1904,13 @@ void tst_QSqlDatabase::odbc_testqGetString() QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + testqGetString + " ORDER BY id")); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 1); - QCOMPARE(q.value(1).toString().length(), 65536); + QCOMPARE(q.value(1).toString().size(), 65536); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 2); - QCOMPARE(q.value(1).toString().length(), 65537); + QCOMPARE(q.value(1).toString().size(), 65537); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 3); - QCOMPARE(q.value(1).toString().length(), 65538); + QCOMPARE(q.value(1).toString().size(), 65538); } @@ -2189,7 +2189,7 @@ void tst_QSqlDatabase::eventNotificationIBase() // Interbase needs some time to post the notification and call the driver callback. // This happends from another thread, and we have to process events in order for the // event handler in the driver to be executed and emit the notification signal. - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), procedureName); QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName)); @@ -2211,7 +2211,7 @@ void tst_QSqlDatabase::eventNotificationPSQL() QVERIFY_SQL(*driver, subscribeToNotification(procedureName)); QSignalSpy spy(driver, QOverload<const QString &, QSqlDriver::NotificationSource, const QVariant &>::of(&QSqlDriver::notification)); query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload)); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), procedureName); QCOMPARE(qvariant_cast<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource); @@ -2237,12 +2237,12 @@ void tst_QSqlDatabase::eventNotificationSQLite() QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER, realVal REAL)")); driver->subscribeToNotification(noEscapeTableName); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)")); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), noEscapeTableName); driver->unsubscribeFromNotification(noEscapeTableName); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, realVal) VALUES (1, 2.3)")); - QTRY_COMPARE(spy.count(), 0); + QTRY_COMPARE(spy.size(), 0); } void tst_QSqlDatabase::sqlite_bindAndFetchUInt() diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index 3a6e16020f..e2877a1157 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -125,10 +125,10 @@ void tst_QSqlDriver::record() QCOMPARE(rec.field(1).length(), 20); if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) - for(int i = 0; i < fields.count(); ++i) + for(int i = 0; i < fields.size(); ++i) fields[i] = fields[i].toUpper(); - for (int i = 0; i < fields.count(); ++i) + for (int i = 0; i < fields.size(); ++i) QCOMPARE(rec.fieldName(i), fields[i]); if (driverSupportsDefaultValues(dbType)) @@ -145,7 +145,7 @@ void tst_QSqlDriver::record() QCOMPARE(rec.count(), 5); } - for (int i = 0; i < fields.count(); ++i) + for (int i = 0; i < fields.size(); ++i) QCOMPARE(rec.fieldName(i), fields[i]); if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 026c9becec..159b968256 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -2221,7 +2221,7 @@ void tst_QSqlQuery::prepare_bind_exec() q.bindValue(":id", i); QVERIFY_SQL(q, exec()); const QVariantList m = q.boundValues(); - QCOMPARE(m.count(), qsizetype(2)); + QCOMPARE(m.size(), qsizetype(2)); QCOMPARE(m.at(0).toInt(), i); QCOMPARE(m.at(1).toString(), values[i]); } @@ -3602,9 +3602,9 @@ void tst_QSqlQuery::task_250026() QVERIFY_SQL(q, exec()); QVERIFY_SQL(q, exec("select * from " + tableName)); QVERIFY_SQL(q, next()); - QCOMPARE(q.value(0).toString().length(), data258.length()); + QCOMPARE(q.value(0).toString().size(), data258.size()); QVERIFY_SQL(q, next()); - QCOMPARE(q.value(0).toString().length(), data1026.length()); + QCOMPARE(q.value(0).toString().size(), data1026.size()); } void tst_QSqlQuery::crashQueryOnCloseDatabase() diff --git a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp index b8fd27bc50..6ef3ad4d19 100644 --- a/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp +++ b/tests/auto/sql/kernel/qsqlresult/tst_qsqlresult.cpp @@ -29,7 +29,7 @@ void tst_QSqlResult::positionalToNamedBinding() TestSqlDriverResult result(&testDriver); QString query("INSERT INTO MYTABLE (ID, NAME, BIRTH) VALUES(?, ?, ?)"); QVERIFY(result.savePrepare(query)); - QCOMPARE(result.boundValues().count(), 3); + QCOMPARE(result.boundValues().size(), 3); } void tst_QSqlResult::parseOfBoundValues() @@ -37,43 +37,43 @@ void tst_QSqlResult::parseOfBoundValues() TestSqlDriver testDriver; TestSqlDriverResult result(&testDriver); QVERIFY(result.savePrepare("SELECT :1 AS \":2\"")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT :1 AS ':2'")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]")); if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) - QCOMPARE(result.boundValues().count(), 2); + QCOMPARE(result.boundValues().size(), 2); else - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]")); if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) - QCOMPARE(result.boundValues().count(), 2); + QCOMPARE(result.boundValues().size(), 2); else - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT :1 AS [:2]]]]]")); if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) - QCOMPARE(result.boundValues().count(), 2); + QCOMPARE(result.boundValues().size(), 2); else - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS \"?\"")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS '?'")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS [?]")); if (testDriver.dbmsType() == QSqlDriver::PostgreSQL) - QCOMPARE(result.boundValues().count(), 2); + QCOMPARE(result.boundValues().size(), 2); else - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS \"'?\"")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS '?\"'")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS '?''?'")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); QVERIFY(result.savePrepare("SELECT ? AS [\"?']")); - QCOMPARE(result.boundValues().count(), 1); + QCOMPARE(result.boundValues().size(), 1); } QTEST_MAIN( tst_QSqlResult ) diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index d868cf0197..a174ea6f37 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -258,7 +258,7 @@ void tst_QSqlThread::generic_data(const QString& engine) void tst_QSqlThread::dropTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); @@ -268,7 +268,7 @@ void tst_QSqlThread::dropTestTables() void tst_QSqlThread::createTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); @@ -285,7 +285,7 @@ void tst_QSqlThread::createTestTables() void tst_QSqlThread::repopulateTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp index 8b7476b3e7..202fc1080c 100644 --- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -202,7 +202,7 @@ void tst_QSqlQueryModel::removeColumn() QCOMPARE(model.columnCount(), 3); QVERIFY(model.removeColumn(0)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(*(QModelIndex *)spy.at(0).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(0).at(1).toInt(), 0); QCOMPARE(spy.at(0).at(2).toInt(), 0); @@ -232,7 +232,7 @@ void tst_QSqlQueryModel::removeColumn() QVERIFY(model.removeColumn(2)); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(*(QModelIndex *)spy.at(1).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(1).at(1).toInt(), 2); QCOMPARE(spy.at(1).at(2).toInt(), 2); @@ -245,7 +245,7 @@ void tst_QSqlQueryModel::removeColumn() QVERIFY(model.removeColumn(1)); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); QVERIFY(*(QModelIndex *)spy.at(2).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(2).at(1).toInt(), 1); QCOMPARE(spy.at(2).at(2).toInt(), 1); @@ -259,7 +259,7 @@ void tst_QSqlQueryModel::removeColumn() QVERIFY(model.removeColumn(0)); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); QVERIFY(*(QModelIndex *)spy.at(3).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(3).at(1).toInt(), 0); QCOMPARE(spy.at(3).at(2).toInt(), 0); @@ -301,7 +301,7 @@ void tst_QSqlQueryModel::insertColumn() QVERIFY(model.insertColumn(1)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(*(QModelIndex *)spy.at(0).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(0).at(1).toInt(), 1); QCOMPARE(spy.at(0).at(2).toInt(), 1); @@ -330,7 +330,7 @@ void tst_QSqlQueryModel::insertColumn() QVERIFY(model.insertColumn(0)); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(*(QModelIndex *)spy.at(1).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(1).at(1).toInt(), 0); QCOMPARE(spy.at(1).at(2).toInt(), 0); @@ -345,7 +345,7 @@ void tst_QSqlQueryModel::insertColumn() QVERIFY(!model.insertColumn(6)); QVERIFY(model.insertColumn(5)); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); QVERIFY(*(QModelIndex *)spy.at(2).at(0).constData() == QModelIndex()); QCOMPARE(spy.at(2).at(1).toInt(), 5); QCOMPARE(spy.at(2).at(2).toInt(), 5); @@ -424,7 +424,7 @@ void tst_QSqlQueryModel::setHeaderData() QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); QVERIFY(model.setHeaderData(2, Qt::Horizontal, "bar")); QCOMPARE(model.headerData(2, Qt::Horizontal).toString(), QString("bar")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::Orientation>(spy.value(0).value(0)), Qt::Horizontal); QCOMPARE(spy.value(0).value(1).toInt(), 2); QCOMPARE(spy.value(0).value(2).toInt(), 2); @@ -452,8 +452,8 @@ void tst_QSqlQueryModel::fetchMore() model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__, db), db)); int rowCount = model.rowCount(); - QCOMPARE(modelAboutToBeResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(modelAboutToBeResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); // If the driver doesn't return the query size fetchMore() causes the // model to grow and new signals are emitted @@ -499,11 +499,11 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QCOMPARE(proxy.rowCount(), 511); // setQuery() resets the model accompanied by begin and end signals - QCOMPARE(modelAboutToBeResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(modelAboutToBeResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); // The call to scrollToBottom() forces the model to fetch additional rows. - QCOMPARE(modelRowsInsertedSpy.count(), 1); + QCOMPARE(modelRowsInsertedSpy.size(), 1); QCOMPARE(modelRowsInsertedSpy.value(0).value(1).toInt(), 256); QCOMPARE(modelRowsInsertedSpy.value(0).value(2).toInt(), 510); } @@ -523,14 +523,14 @@ void tst_QSqlQueryModel::setQuerySignalEmission() // First select, the model was empty and no rows had to be removed, but model resets anyway. model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db)); - QCOMPARE(modelAboutToBeResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(modelAboutToBeResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); // Second select, the model wasn't empty and two rows had to be removed! // setQuery() resets the model accompanied by begin and end signals model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db)); - QCOMPARE(modelAboutToBeResetSpy.count(), 2); - QCOMPARE(modelResetSpy.count(), 2); + QCOMPARE(modelAboutToBeResetSpy.size(), 2); + QCOMPARE(modelResetSpy.size(), 2); } // For task 170783: When the query's result set is empty no rows should be inserted, @@ -549,8 +549,8 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet() QSqlQuery query(db); QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__, db) + " where 0 = 1")); model.setQuery(std::move(query)); - QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0); - QCOMPARE(modelRowsInsertedSpy.count(), 0); + QCOMPARE(modelRowsAboutToBeInsertedSpy.size(), 0); + QCOMPARE(modelRowsInsertedSpy.size(), 0); } class NestedResetsTest: public QSqlQueryModel diff --git a/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp b/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp index 5c49600b8f..1a9f8310c9 100644 --- a/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp +++ b/tests/auto/sql/models/qsqlrelationaldelegate/tst_qsqlrelationaldelegate.cpp @@ -146,7 +146,7 @@ void tst_QSqlRelationalDelegate::comboBoxEditor() tv.setCurrentIndex(index); tv.edit(index); QList<QComboBox*> comboBoxes = tv.viewport()->findChildren<QComboBox *>(); - QCOMPARE(comboBoxes.count(), 1); + QCOMPARE(comboBoxes.size(), 1); QComboBox *editor = comboBoxes.at(0); QCOMPARE(editor->currentText(), "herr"); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index ebddefb5fd..ece99efa0a 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -148,7 +148,7 @@ tst_QSqlTableModel::~tst_QSqlTableModel() void tst_QSqlTableModel::dropTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); @@ -177,7 +177,7 @@ void tst_QSqlTableModel::dropTestTables() void tst_QSqlTableModel::createTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); QSqlQuery q(db); @@ -207,7 +207,7 @@ void tst_QSqlTableModel::createTestTables() void tst_QSqlTableModel::repopulateTestTables() { - for (int i = 0; i < dbs.dbNames.count(); ++i) { + for (int i = 0; i < dbs.dbNames.size(); ++i) { QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); const auto test = qTableName("test1", __FILE__, db); @@ -602,8 +602,8 @@ void tst_QSqlTableModel::setRecord() // dataChanged() emitted by setData() for each *changed* column if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) { - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(0).count(), 2); + QCOMPARE(spy.size(), 2); + QCOMPARE(spy.at(0).size(), 2); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1)); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1)); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(0)), model.index(i, 2)); @@ -614,10 +614,10 @@ void tst_QSqlTableModel::setRecord() else { if ((QSqlTableModel::EditStrategy)submitpolicy != QSqlTableModel::OnManualSubmit) // dataChanged() also emitted by selectRow() - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); else - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(0).count(), 2); + QCOMPARE(spy.size(), 2); + QCOMPARE(spy.at(0).size(), 2); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1)); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1)); QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(0)), model.index(i, 2)); @@ -1092,7 +1092,7 @@ void tst_QSqlTableModel::removeRow() QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); QVERIFY(model.removeRow(1)); - QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(headerDataChangedSpy.at(0).value(0).constData()), Qt::Vertical); QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1); QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1); @@ -1112,7 +1112,7 @@ void tst_QSqlTableModel::removeRow() headerDataChangedSpy.clear(); QVERIFY(model.removeRow(1)); - QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy.size(), 1); QCOMPARE(model.rowCount(), 3); QVERIFY_SQL(model, select()); @@ -1148,7 +1148,7 @@ void tst_QSqlTableModel::removeRows() QVERIFY_SQL(model, removeRows(0, 1)); QVERIFY_SQL(model, removeRows(1, 1)); - QCOMPARE(beforeDeleteSpy.count(), 2); + QCOMPARE(beforeDeleteSpy.size(), 2); QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0); QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1); // deleted rows shown as empty until select @@ -1179,15 +1179,15 @@ void tst_QSqlTableModel::removeRows() qRegisterMetaType<Qt::Orientation>("Qt::Orientation"); QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); QVERIFY(model.removeRows(0, 2, QModelIndex())); - QCOMPARE(headerDataChangedSpy.count(), 2); + QCOMPARE(headerDataChangedSpy.size(), 2); QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1); QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1); QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0); QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0); QCOMPARE(model.rowCount(), 3); - QCOMPARE(beforeDeleteSpy.count(), 0); + QCOMPARE(beforeDeleteSpy.size(), 0); QVERIFY(model.submitAll()); - QCOMPARE(beforeDeleteSpy.count(), 2); + QCOMPARE(beforeDeleteSpy.size(), 2); QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0); QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1); QCOMPARE(model.rowCount(), 1); @@ -1784,8 +1784,8 @@ void tst_QSqlTableModel::setFilter() model.setFilter("id = 2"); // check the signals - QCOMPARE(modelAboutToBeResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(modelAboutToBeResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); QCOMPARE(model.rowCount(), 1); QCOMPARE(model.data(model.index(0, 0)).toInt(), 2); @@ -1928,8 +1928,8 @@ void tst_QSqlTableModel::insertRecordsInLoop() model.submitAll(); // submitAll() calls select() which clears and repopulates the table // model emits reset signals - QCOMPARE(modelAboutToBeResetSpy.count(), 1); - QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(modelAboutToBeResetSpy.size(), 1); + QCOMPARE(modelResetSpy.size(), 1); QCOMPARE(model.rowCount(), 13); QCOMPARE(model.columnCount(), 3); diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index ac7336e8e3..8b0319679f 100644 --- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp +++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp @@ -79,15 +79,15 @@ void tst_QSignalSpy::spyWithoutArgs() QtTestObject obj; QSignalSpy spy(&obj, SIGNAL(sig0())); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); emit obj.sig0(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); emit obj.sig0(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 0); + QCOMPARE(args.size(), 0); } void tst_QSignalSpy::spyWithBasicArgs() @@ -96,10 +96,10 @@ void tst_QSignalSpy::spyWithBasicArgs() QSignalSpy spy(&obj, SIGNAL(sig1(int,int))); emit obj.sig1(1, 2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(args.at(0).toInt(), 1); QCOMPARE(args.at(1).toInt(), 2); @@ -107,7 +107,7 @@ void tst_QSignalSpy::spyWithBasicArgs() emit obj.sigLong(1l, 2l); args = spyl.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(qvariant_cast<long>(args.at(0)), 1l); QCOMPARE(qvariant_cast<long>(args.at(1)), 2l); } @@ -124,10 +124,10 @@ void tst_QSignalSpy::spyWithPointers() int i2 = 2; emit obj.sig2(&i1, &i2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1); QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2); } @@ -155,15 +155,15 @@ void tst_QSignalSpy::spyWithBasicQtClasses() QSignalSpy spy(&obj, SIGNAL(sig(QString))); emit obj.sig(QString("bubu")); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).toString(), QString("bubu")); QSignalSpy spy2(&obj, SIGNAL(sig5(QVariant))); QVariant val(45); emit obj.sig5(val); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy2.at(0).count(), 1); + QCOMPARE(spy2.size(), 1); + QCOMPARE(spy2.at(0).size(), 1); QCOMPARE(spy2.at(0).at(0), val); QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val); } @@ -176,8 +176,8 @@ void tst_QSignalSpy::spyWithQtClasses() QSignalSpy spy(&obj, SIGNAL(sig2(QDateTime))); QDateTime dt = QDateTime::currentDateTime(); emit obj.sig2(dt); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime"); QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt); QCOMPARE(spy.at(0).at(0).toDateTime(), dt); @@ -248,7 +248,7 @@ void tst_QSignalSpy::wait_signalEmittedTooLate() QTimer::singleShot(500, this, SIGNAL(sigFoo())); QSignalSpy spy(this, SIGNAL(sigFoo())); QVERIFY(!spy.wait(200)); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); } void tst_QSignalSpy::wait_signalEmittedMultipleTimes() @@ -257,13 +257,13 @@ void tst_QSignalSpy::wait_signalEmittedMultipleTimes() QTimer::singleShot(800, this, SIGNAL(sigFoo())); QSignalSpy spy(this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 1); // we don't wait for the second signal... + QCOMPARE(spy.size(), 1); // we don't wait for the second signal... QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(!spy.wait(1)); QTimer::singleShot(10, this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QSignalSpy::spyFunctionPointerWithoutArgs() @@ -271,15 +271,15 @@ void tst_QSignalSpy::spyFunctionPointerWithoutArgs() QtTestObject obj; QSignalSpy spy(&obj, &QtTestObject::sig0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); emit obj.sig0(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); emit obj.sig0(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 0); + QCOMPARE(args.size(), 0); } void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() @@ -288,10 +288,10 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() QSignalSpy spy(&obj, &QtTestObject::sig1); emit obj.sig1(1, 2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(args.at(0).toInt(), 1); QCOMPARE(args.at(1).toInt(), 2); @@ -299,7 +299,7 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() emit obj.sigLong(1l, 2l); args = spyl.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(qvariant_cast<long>(args.at(0)), 1l); QCOMPARE(qvariant_cast<long>(args.at(1)), 2l); } @@ -316,10 +316,10 @@ void tst_QSignalSpy::spyFunctionPointerWithPointers() int i2 = 2; emit obj.sig2(&i1, &i2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1); QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2); } @@ -330,15 +330,15 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicQtClasses() QSignalSpy spy(&obj, &QtTestObject2::sig); emit obj.sig(QString("bubu")); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).toString(), QString("bubu")); QSignalSpy spy2(&obj, &QtTestObject2::sig5); QVariant val(45); emit obj.sig5(val); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy2.at(0).count(), 1); + QCOMPARE(spy2.size(), 1); + QCOMPARE(spy2.at(0).size(), 1); QCOMPARE(spy2.at(0).at(0), val); QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val); } @@ -350,8 +350,8 @@ void tst_QSignalSpy::spyFunctionPointerWithQtClasses() QSignalSpy spy(&obj, &QtTestObject2::sig2); QDateTime dt = QDateTime::currentDateTime(); emit obj.sig2(dt); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime"); QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt); QCOMPARE(spy.at(0).at(0).toDateTime(), dt); @@ -373,8 +373,8 @@ void tst_QSignalSpy::spyFunctionPointerWithCustomClass() { QSignalSpy spy(&obj, &QtTestObject2::sig6); emit obj.sig6({}); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "CustomType"); } @@ -420,7 +420,7 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedTooLate() QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); QVERIFY(!spy.wait(200)); QTest::qWait(400); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes() @@ -429,13 +429,13 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes() QTimer::singleShot(800, this, SIGNAL(sigFoo())); QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 1); // we don't wait for the second signal... + QCOMPARE(spy.size(), 1); // we don't wait for the second signal... QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(!spy.wait(1)); QTimer::singleShot(10, this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QSignalSpy::spyOnMetaMethod() @@ -454,7 +454,7 @@ void tst_QSignalSpy::spyOnMetaMethod() QVERIFY(spy.isValid()); obj.setObjectName("A new object name"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } Q_DECLARE_METATYPE(QMetaMethod); diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp index cb69905c34..ec54f786d9 100644 --- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp @@ -180,16 +180,16 @@ int main(int argc, char** argv) if (badstring == -1) { tst_BadXml test; - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } QList<QByteArray> badstrings = tst_BadXml::badStrings(); - if (badstring >= badstrings.count()) + if (badstring >= badstrings.size()) qFatal("`-badstring %d' is out of range", badstring); tst_BadXmlSub test; test.className = badstrings[badstring].constData(); - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } #include "tst_badxml.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 13670257dd..f6c97bc345 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -432,8 +432,8 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) // format: // "function","[globaltag:]tag","metric",value_per_iteration,total,iterations QStringList split = line.split(','); - if (split.count() != 6) { - if (error) *error = QString("Wrong number of columns (%1)").arg(split.count()); + if (split.size() != 6) { + if (error) *error = QString("Wrong number of columns (%1)").arg(split.size()); return out; } diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index c03fb44791..ba23e05525 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -124,7 +124,7 @@ void tst_qmake::initTestCase() QString testDataPath = QFINDTESTDATA(subProgram); if (!testDataPath.endsWith(subProgram)) QFAIL("Cannot find test data directory."); - testDataPath.chop(subProgram.length() - testDataSubDir.length()); + testDataPath.chop(subProgram.size() - testDataSubDir.size()); QString userWorkDir = qgetenv("TST_QMAKE_BUILD_DIR"); if (userWorkDir.isEmpty()) { diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index bddaeba042..8e6d7eada2 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2800,7 +2800,7 @@ static bool compareState(QMakeEvaluator *eval, ProFile *out) } ProValueMap::Iterator it; ProValueMap *vmap = eval->findValues(var, &it); - if (value.length() == 1 && value.at(0) == "UNDEF") { + if (value.size() == 1 && value.at(0) == "UNDEF") { if (vmap) { qWarning("Value of %s is incorrect.\n Actual:%s\nExpected: <UNDEFINED>", qPrintable(var.toQString()), diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp index 7d2f59dc83..a35864811a 100644 --- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp +++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp @@ -77,7 +77,7 @@ void tst_QColorDialog::native_activeModalWidget() void tst_QColorDialog::postKeyReturn() { QWidgetList list = QApplication::topLevelWidgets(); - for (int i=0; i<list.count(); ++i) { + for (int i=0; i<list.size(); ++i) { QColorDialog *dialog = qobject_cast<QColorDialog *>(list[i]); if (dialog) { QTest::keyClick( list[i], Qt::Key_Return, Qt::NoModifier ); diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index b2b2e026f7..3b43e765d9 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -694,7 +694,7 @@ void tst_QDialog::virtualsOnClose() // Qt doesn't deliver events to QWidgets closed during destruction QCOMPARE(filter.closeEventCount, 0); // QDialog doesn't emit signals when closed by destruction - QCOMPARE(rejectedSpy.count(), 0); + QCOMPARE(rejectedSpy.size(), 0); } } @@ -747,7 +747,7 @@ void tst_QDialog::quitOnDone() // also quit with a timer in case the test fails QTimer::singleShot(1000, QApplication::instance(), &QApplication::quit); QApplication::exec(); - QCOMPARE(quitSpy.count(), 1); + QCOMPARE(quitSpy.size(), 1); } void tst_QDialog::focusWidgetAfterOpen() diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index e0d091c3bd..8fa9061066 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -206,7 +206,7 @@ void tst_QFiledialog::currentChangedSignal() QVERIFY(listView->model()->hasChildren(folder)); listView->setCurrentIndex(folder); - QCOMPARE(spyCurrentChanged.count(), 1); + QCOMPARE(spyCurrentChanged.size(), 1); } // only emitted from the views, sidebar, or lookin combo @@ -228,7 +228,7 @@ void tst_QFiledialog::directoryEnteredSignal() QVERIFY(secondItem.isValid()); sidebar->setCurrentIndex(secondItem); QTest::keyPress(sidebar->viewport(), Qt::Key_Return); - QCOMPARE(spyDirectoryEntered.count(), 1); + QCOMPARE(spyDirectoryEntered.size(), 1); spyDirectoryEntered.clear(); // lookInCombo @@ -237,7 +237,7 @@ void tst_QFiledialog::directoryEnteredSignal() QVERIFY(comboBox->view()->model()->index(1, 0).isValid()); comboBox->view()->setCurrentIndex(comboBox->view()->model()->index(1, 0)); QTest::keyPress(comboBox->view()->viewport(), Qt::Key_Return); - QCOMPARE(spyDirectoryEntered.count(), 1); + QCOMPARE(spyDirectoryEntered.size(), 1); spyDirectoryEntered.clear(); // view @@ -314,7 +314,7 @@ void tst_QFiledialog::filesSelectedSignal() QVERIFY(button->isEnabled()); button->animateClick(); QTRY_COMPARE(fd.isVisible(), false); - QCOMPARE(spyFilesSelected.count(), 1); + QCOMPARE(spyFilesSelected.size(), 1); } // only emitted when the combo box is activated @@ -339,7 +339,7 @@ void tst_QFiledialog::filterSelectedSignal() QTest::keyPress(filters, Qt::Key_Down); - QCOMPARE(spyFilterSelected.count(), 1); + QCOMPARE(spyFilterSelected.size(), 1); } void tst_QFiledialog::args() @@ -380,14 +380,14 @@ void tst_QFiledialog::directory() #ifndef Q_OS_WIN QCOMPARE(tempPath, fd.directory().absolutePath()); #endif - QCOMPARE(spyCurrentChanged.count(), 0); - QCOMPARE(spyDirectoryEntered.count(), 0); - QCOMPARE(spyFilesSelected.count(), 0); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyCurrentChanged.size(), 0); + QCOMPARE(spyDirectoryEntered.size(), 0); + QCOMPARE(spyFilesSelected.size(), 0); + QCOMPARE(spyFilterSelected.size(), 0); // Check my way QList<QListView*> list = fd.findChildren<QListView*>("listView"); - QVERIFY(list.count() > 0); + QVERIFY(list.size() > 0); #ifdef Q_OS_WIN QCOMPARE(list.at(0)->rootIndex().data().toString().toLower(), temp.dirName().toLower()); #else @@ -572,16 +572,16 @@ void tst_QFiledialog::completer_up() fd.show(); QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); - QCOMPARE(spyFilesSelected.count(), 0); - int depth = QDir::currentPath().split('/').count(); + QCOMPARE(spyFilesSelected.size(), 0); + int depth = QDir::currentPath().split('/').size(); for (int i = 0; i <= depth * 3 + 1; ++i) { lineEdit->insert("../"); qApp->processEvents(); } - QCOMPARE(spyCurrentChanged.count(), 0); - QCOMPARE(spyDirectoryEntered.count(), 0); - QCOMPARE(spyFilesSelected.count(), 0); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyCurrentChanged.size(), 0); + QCOMPARE(spyDirectoryEntered.size(), 0); + QCOMPARE(spyFilesSelected.size(), 0); + QCOMPARE(spyFilterSelected.size(), 0); } void tst_QFiledialog::acceptMode() @@ -661,7 +661,7 @@ void tst_QFiledialog::filters() // effects QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo"); - QCOMPARE(views.count(), 1); + QCOMPARE(views.size(), 1); QCOMPARE(views.at(0)->isVisible(), false); QStringList filters; @@ -676,15 +676,15 @@ void tst_QFiledialog::filters() QCOMPARE(fd.nameFilters(), filters); fd.setNameFilter("Image files (*.png *.xpm *.jpg);;Text files (*.txt);;Any files (*.*)"); QCOMPARE(fd.nameFilters(), filters); - QCOMPARE(spyCurrentChanged.count(), 0); - QCOMPARE(spyDirectoryEntered.count(), 0); - QCOMPARE(spyFilesSelected.count(), 0); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyCurrentChanged.size(), 0); + QCOMPARE(spyDirectoryEntered.size(), 0); + QCOMPARE(spyFilesSelected.size(), 0); + QCOMPARE(spyFilterSelected.size(), 0); // setting shouldn't emit any signals for (int i = views.at(0)->currentIndex(); i < views.at(0)->count(); ++i) views.at(0)->setCurrentIndex(i); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyFilterSelected.size(), 0); //Let check if filters with whitespaces QFileDialog fd2; @@ -723,7 +723,7 @@ void tst_QFiledialog::selectFilter() QCOMPARE(fd.selectedNameFilter(), filters.at(2)); fd.selectNameFilter(""); QCOMPARE(fd.selectedNameFilter(), filters.at(2)); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyFilterSelected.size(), 0); } void tst_QFiledialog::history() @@ -762,10 +762,10 @@ void tst_QFiledialog::history() badHistory << QDir::toNativeSeparators(QDir::current().absolutePath()); QCOMPARE(fd.history(), badHistory); - QCOMPARE(spyCurrentChanged.count(), 0); - QCOMPARE(spyDirectoryEntered.count(), 0); - QCOMPARE(spyFilesSelected.count(), 0); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(spyCurrentChanged.size(), 0); + QCOMPARE(spyDirectoryEntered.size(), 0); + QCOMPARE(spyFilesSelected.size(), 0); + QCOMPARE(spyFilterSelected.size(), 0); } void tst_QFiledialog::iconProvider() @@ -868,7 +868,7 @@ void tst_QFiledialog::selectFile() QVERIFY(model); fd->setDirectory(QDir::currentPath()); // default value - QCOMPARE(fd->selectedFiles().count(), 1); + QCOMPARE(fd->selectedFiles().size(), 1); QScopedPointer<QTemporaryFile> tempFile; if (file == QLatin1String("temp")) { @@ -878,7 +878,7 @@ void tst_QFiledialog::selectFile() } fd->selectFile(file); - QCOMPARE(fd->selectedFiles().count(), count); + QCOMPARE(fd->selectedFiles().size(), count); if (tempFile.isNull()) { QCOMPARE(model->index(fd->directory().path()), model->index(QDir::currentPath())); } else { @@ -935,29 +935,29 @@ void tst_QFiledialog::selectFiles() // Get a list of files in the view and then get the corresponding index's QStringList list = fd.directory().entryList(QDir::Files); QModelIndexList toSelect; - QVERIFY(list.count() > 1); + QVERIFY(list.size() > 1); QListView* listView = fd.findChild<QListView*>("listView"); QVERIFY(listView); - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { fd.selectFile(fd.directory().path() + QLatin1Char('/') + list.at(i)); QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty()); toSelect.append(listView->selectionModel()->selectedRows().last()); } - QCOMPARE(spyFilesSelected.count(), 0); + QCOMPARE(spyFilesSelected.size(), 0); listView->selectionModel()->clear(); - QCOMPARE(spyFilesSelected.count(), 0); + QCOMPARE(spyFilesSelected.size(), 0); // select the indexes - for (int i = 0; i < toSelect.count(); ++i) { + for (int i = 0; i < toSelect.size(); ++i) { listView->selectionModel()->select(toSelect.at(i), QItemSelectionModel::Select | QItemSelectionModel::Rows); } - QCOMPARE(fd.selectedFiles().count(), toSelect.count()); - QCOMPARE(spyCurrentChanged.count(), 0); - QCOMPARE(spyDirectoryEntered.count(), 0); - QCOMPARE(spyFilesSelected.count(), 0); - QCOMPARE(spyFilterSelected.count(), 0); + QCOMPARE(fd.selectedFiles().size(), toSelect.size()); + QCOMPARE(spyCurrentChanged.size(), 0); + QCOMPARE(spyDirectoryEntered.size(), 0); + QCOMPARE(spyFilesSelected.size(), 0); + QCOMPARE(spyFilterSelected.size(), 0); } @@ -983,13 +983,13 @@ void tst_QFiledialog::viewMode() // find widgets QList<QTreeView*> treeView = fd.findChildren<QTreeView*>("treeView"); - QCOMPARE(treeView.count(), 1); + QCOMPARE(treeView.size(), 1); QList<QListView*> listView = fd.findChildren<QListView*>("listView"); - QCOMPARE(listView.count(), 1); + QCOMPARE(listView.size(), 1); QList<QToolButton*> listButton = fd.findChildren<QToolButton*>("listModeButton"); - QCOMPARE(listButton.count(), 1); + QCOMPARE(listButton.size(), 1); QList<QToolButton*> treeButton = fd.findChildren<QToolButton*>("detailModeButton"); - QCOMPARE(treeButton.count(), 1); + QCOMPARE(treeButton.size(), 1); // default value QCOMPARE(fd.viewMode(), QFileDialog::List); @@ -1128,7 +1128,7 @@ void tst_QFiledialog::focus() QCursor::setPos(fd.geometry().center()); QList<QWidget*> treeView = fd.findChildren<QWidget*>("fileNameEdit"); - QCOMPARE(treeView.count(), 1); + QCOMPARE(treeView.size(), 1); QVERIFY(treeView.at(0)); QTRY_COMPARE(treeView.at(0)->hasFocus(), true); QCOMPARE(treeView.at(0)->hasFocus(), true); @@ -1158,13 +1158,13 @@ void tst_QFiledialog::historyBack() QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), false); fd.setDirectory(desktop); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); backButton->click(); qApp->processEvents(); QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), true); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); QString currentPath = qvariant_cast<QString>(spy.last().first()); QCOMPARE(model->index(currentPath), model->index(temp)); @@ -1173,11 +1173,11 @@ void tst_QFiledialog::historyBack() QCOMPARE(currentPath, home); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); // nothing should change at this point backButton->click(); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); } @@ -1211,7 +1211,7 @@ void tst_QFiledialog::historyForward() QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(desktop)); QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), false); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); backButton->click(); QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); @@ -1221,13 +1221,13 @@ void tst_QFiledialog::historyForward() QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home)); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); - QCOMPARE(spy.count(), 6); + QCOMPARE(spy.size(), 6); forwardButton->click(); QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); backButton->click(); QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home)); - QCOMPARE(spy.count(), 8); + QCOMPARE(spy.size(), 8); forwardButton->click(); QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 0ece2c1156..fc12b2dc82 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -803,8 +803,8 @@ void tst_QFileDialog2::task235069_hideOnEscape() child->setFocus(); QTest::keyClick(child, Qt::Key_Escape); QCOMPARE(fd.isVisible(), false); - QCOMPARE(spyFinished.count(), 1); // QTBUG-7690 - QCOMPARE(spyRejected.count(), 1); // reject(), don't hide() + QCOMPARE(spyFinished.size(), 1); // QTBUG-7690 + QCOMPARE(spyRejected.size(), 1); // reject(), don't hide() } #ifdef QT_BUILD_INTERNAL @@ -1026,10 +1026,10 @@ public : void removeSelection() { QList<QModelIndex> idxs = selectionModel()->selectedIndexes(); QList<QPersistentModelIndex> indexes; - for (int i = 0; i < idxs.count(); i++) + for (int i = 0; i < idxs.size(); i++) indexes.append(idxs.at(i)); - for (int i = 0; i < indexes.count(); ++i) + for (int i = 0; i < indexes.size(); ++i) if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty()) model()->removeRow(indexes.at(i).row()); } @@ -1131,7 +1131,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes() QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt")); QListView *list = fd.findChild<QListView*>("listView"); QVERIFY(list); - QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0); + QCOMPARE(list->selectionModel()->selectedRows(0).size(), 0); t->deleteLater(); } @@ -1147,7 +1147,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() QFileDialog fd; fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url)); QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); - QCOMPARE(sidebar->urls().count(), 1); + QCOMPARE(sidebar->urls().size(), 1); QVERIFY(sidebar->urls().first().toLocalFile() != url); QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url)); diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 828eaa7214..0a77bc3808 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -76,7 +76,7 @@ void tst_QFontDialog::cleanup() void tst_QFontDialog::postKeyReturn() { QWidgetList list = QApplication::topLevelWidgets(); - for (int i=0; i<list.count(); ++i) { + for (int i=0; i<list.size(); ++i) { QFontDialog *dialog = qobject_cast<QFontDialog*>(list[i]); if (dialog) { QTest::keyClick( list[i], Qt::Key_Return, Qt::NoModifier ); @@ -215,7 +215,7 @@ void tst_QFontDialog::testNonStandardFontSize() QList<int> standardSizesList = QFontDatabase::standardSizes(); int nonStandardFontSize; if (!standardSizesList.isEmpty()) { - nonStandardFontSize = standardSizesList.at(standardSizesList.count()-1); // get the maximum standard size. + nonStandardFontSize = standardSizesList.at(standardSizesList.size()-1); // get the maximum standard size. nonStandardFontSize += 1; // the increment of 1 to mock a non-standard font size. } else { QSKIP("QFontDatabase::standardSizes() is empty."); diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 5dbb47ce59..3336504f7a 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -636,7 +636,7 @@ void tst_QMessageBox::acceptedRejectedSignals() button->click(); if (roles.contains(messageBox.buttonRole(button))) - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); else QVERIFY(spy.isEmpty()); } diff --git a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp index c4a2ffa2fd..167c4bf8f1 100644 --- a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp +++ b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp @@ -38,9 +38,9 @@ void tst_QSidebar::setUrls() QCOMPARE(model->rowCount(), 0); qsidebar.setUrls(urls); QCOMPARE(qsidebar.urls(), urls); - QCOMPARE(model->rowCount(), urls.count()); + QCOMPARE(model->rowCount(), urls.size()); qsidebar.setUrls(urls); - QCOMPARE(model->rowCount(), urls.count()); + QCOMPARE(model->rowCount(), urls.size()); } void tst_QSidebar::selectUrls() @@ -55,7 +55,7 @@ void tst_QSidebar::selectUrls() QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl))); qsidebar.selectUrl(urls.at(0)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QSidebar::addUrls() @@ -171,7 +171,7 @@ void tst_QSidebar::goToUrl() QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl))); QTest::mousePress(qsidebar.viewport(), Qt::LeftButton, {}, qsidebar.visualRect(qsidebar.model()->index(0, 0)).center()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((spy.value(0)).at(0).toUrl(), urls.first()); } diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 2a0ba93803..ad079889b2 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -522,7 +522,7 @@ void tst_QWizard::addPage() QCOMPARE(wizard.addPage(pages[i]), i); QCOMPARE(pages[i]->window(), (QWidget *)&wizard); QCOMPARE(wizard.startId(), 0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), i); } @@ -535,29 +535,29 @@ void tst_QWizard::addPage() QVERIFY(!wizard.page(N + 1)); wizard.setPage(N + 50, new QWizardPage); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), N + 50); wizard.setPage(-3000, new QWizardPage); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), -3000); QWizardPage *pageX = new QWizardPage; QCOMPARE(wizard.addPage(pageX), N + 51); QCOMPARE(wizard.page(N + 51), pageX); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), N + 51); QCOMPARE(wizard.addPage(new QWizardPage), N + 52); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), N + 52); QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert null page"); wizard.addPage(0); // generates a warning - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); delete parent; } @@ -584,7 +584,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert page with ID -1"); wizard.setPage(-1, page); // gives a warning and does nothing - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(!wizard.page(-2)); QVERIFY(!wizard.page(-1)); QVERIFY(!wizard.page(0)); @@ -596,7 +596,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(0, page); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(page->window(), (QWidget *)&wizard); @@ -609,7 +609,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(-2, page); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), -2); QCOMPARE(page->window(), (QWidget *)&wizard); @@ -630,7 +630,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(2, page); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.page(2), page); @@ -649,7 +649,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(-3, page); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), -3); QCOMPARE(wizard.page(-3), page); @@ -720,7 +720,7 @@ void tst_QWizard::setPage() QCOMPARE(wizard.nextId(), -2); CHECK_VISITED(wizard, QList<int>() << -3); } - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); delete parent; } @@ -1693,7 +1693,7 @@ public: void createTestRows() { - for (int i = 0; i < combinations.count(); ++i) { + for (int i = 0; i < combinations.size(); ++i) { QTest::newRow((name.toLatin1() + ", row " + QByteArray::number(i)).constData()) << (i == 0) << (type == Equality) << combinations.at(i); ++nRows_; @@ -2129,19 +2129,19 @@ void tst_QWizard::showCurrentPageOnly() wizard.show(); - QCOMPARE(pages.shown().count(), 1); + QCOMPARE(pages.shown().size(), 1); QCOMPARE(pages.shown().first(), pages.all().first()); const int steps = 2; for (int i = 0; i < steps; ++i) wizard.next(); - QCOMPARE(pages.shown().count(), 1); + QCOMPARE(pages.shown().size(), 1); QCOMPARE(pages.shown().first(), pages.all().at(steps)); wizard.restart(); - QCOMPARE(pages.shown().count(), 1); + QCOMPARE(pages.shown().size(), 1); QCOMPARE(pages.shown().first(), pages.all().first()); } @@ -2273,36 +2273,36 @@ void tst_QWizard::removePage() wizard.restart(); QCOMPARE(wizard.pageIds().size(), 4); QCOMPARE(wizard.visitedIds().size(), 1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Removing a non-existent page wizard.removePage(4); QCOMPARE(wizard.pageIds().size(), 4); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Removing and then reinserting a page QCOMPARE(wizard.pageIds().size(), 4); QVERIFY(wizard.pageIds().contains(2)); wizard.removePage(2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); wizard.setPage(2, page2); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(wizard.pageIds().size(), 4); QVERIFY(wizard.pageIds().contains(2)); // Removing the same page twice wizard.removePage(2); // restore - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); wizard.removePage(2); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); @@ -2312,9 +2312,9 @@ void tst_QWizard::removePage() wizard.next(); QCOMPARE(wizard.visitedIds().size(), 2); QCOMPARE(wizard.currentPage(), page1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); wizard.removePage(2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.visitedIds().size(), 2); @@ -2325,11 +2325,11 @@ void tst_QWizard::removePage() wizard.setPage(2, page2); // restore wizard.restart(); wizard.next(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(wizard.visitedIds().size(), 2); QCOMPARE(wizard.currentPage(), page1); wizard.removePage(0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(wizard.visitedIds().size(), 1); @@ -2341,11 +2341,11 @@ void tst_QWizard::removePage() wizard.setPage(0, page0); // restore wizard.restart(); wizard.next(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(wizard.visitedIds().size(), 2); QCOMPARE(wizard.currentPage(), page1); wizard.removePage(1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 1); QCOMPARE(wizard.visitedIds().size(), 1); @@ -2355,7 +2355,7 @@ void tst_QWizard::removePage() // Remove the current page which is the first (and only) one in the history wizard.removePage(0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(wizard.visitedIds().size(), 1); @@ -2365,7 +2365,7 @@ void tst_QWizard::removePage() QCOMPARE(wizard.currentPage(), page2); // wizard.removePage(2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.visitedIds().size(), 1); @@ -2375,7 +2375,7 @@ void tst_QWizard::removePage() QCOMPARE(wizard.currentPage(), page3); // wizard.removePage(3); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 3); QVERIFY(wizard.visitedIds().empty()); diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 8b4d8b0b68..e1cccaadc9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1663,7 +1663,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Determine amount of widgets to add. int widgetCount = -1; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; widgetCount = qMax(widgetCount, item.firstIndex); widgetCount = qMax(widgetCount, item.secondIndex); @@ -1678,7 +1678,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Setup anchor layout TheAnchorLayout *layout = new TheAnchorLayout; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; layout->setAnchor( getItem(item.firstIndex, widgets, layout), @@ -1695,7 +1695,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(widget->size(), size); // Validate - for (int i = 0; i < result.count(); ++i) { + for (int i = 0; i < result.size(); ++i) { const BasicLayoutTestResult item = result[i]; QRectF expected = item.rect; QRectF actual = widgets[item.index]->geometry(); @@ -1707,7 +1707,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() widget->setLayoutDirection(Qt::RightToLeft); layout->activate(); // Validate - for (int j = 0; j < result.count(); ++j) { + for (int j = 0; j < result.size(); ++j) { const BasicLayoutTestResult item = result[j]; QRectF mirroredRect(item.rect); // only valid cases are mirrored @@ -2168,7 +2168,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() // Determine amount of widgets to add. int widgetCount = -1; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; widgetCount = qMax(widgetCount, item.firstIndex); widgetCount = qMax(widgetCount, item.secondIndex); @@ -2185,7 +2185,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() // Setup anchor layout TheAnchorLayout *layout = new TheAnchorLayout; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; layout->setAnchor( getItem(item.firstIndex, widgets, layout), @@ -2195,7 +2195,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() item.spacing ); } - for (int i = 0; i < removeData.count(); ++i) { + for (int i = 0; i < removeData.size(); ++i) { const BasicLayoutTestData item = removeData[i]; layout->removeAnchor( getItem(item.firstIndex, widgets, layout), @@ -2211,7 +2211,7 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() QCOMPARE(widget->size(), size); // Validate - for (int i = 0; i < result.count(); ++i) { + for (int i = 0; i < result.size(); ++i) { const BasicLayoutTestResult item = result[i]; QCOMPARE(widgets[item.index]->geometry(), item.rect); @@ -2999,7 +2999,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases() // Determine amount of widgets to add. int widgetCount = -1; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; widgetCount = qMax(widgetCount, item.firstIndex); widgetCount = qMax(widgetCount, item.secondIndex); @@ -3025,7 +3025,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases() // Setup anchor layout TheAnchorLayout *layout = new TheAnchorLayout; - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { const BasicLayoutTestData item = data[i]; layout->setAnchor( getItem(item.firstIndex, widgets, layout), @@ -3042,7 +3042,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases() QCOMPARE(widget->size(), size); // Validate - for (int i = 0; i < result.count(); ++i) { + for (int i = 0; i < result.size(); ++i) { const BasicLayoutTestResult item = result[i]; QCOMPARE(widgets[item.index]->geometry(), item.rect); } @@ -3051,7 +3051,7 @@ void tst_QGraphicsAnchorLayout1::testComplexCases() widget->setLayoutDirection(Qt::RightToLeft); layout->activate(); // Validate - for (int j = 0; j < result.count(); ++j) { + for (int j = 0; j < result.size(); ++j) { const BasicLayoutTestResult item = result[j]; QRectF mirroredRect(item.rect); // only valid cases are mirrored diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index f4b3a5ef99..9af5433388 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -1658,7 +1658,7 @@ void tst_QGraphicsGridLayout::sizeHint() widget->setContentsMargins(0, 0, 0, 0); int i; - for (i = 0; i < itemDescriptions.count(); ++i) { + for (i = 0; i < itemDescriptions.size(); ++i) { ItemDesc desc = itemDescriptions.at(i); RectWidget *item = new RectWidget(widget); desc.apply(layout, item); @@ -2159,7 +2159,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors() widget->setContentsMargins(0, 0, 0, 0); int i; - for (i = 0; i < itemDescriptions.count(); ++i) { + for (i = 0; i < itemDescriptions.size(); ++i) { ItemDesc desc = itemDescriptions.at(i); RectWidget *item = new RectWidget(widget); desc.apply(layout, item); @@ -2174,7 +2174,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors() widget->resize(newSize); QApplication::sendPostedEvents(0, 0); - for (i = 0; i < expectedSizes.count(); ++i) { + for (i = 0; i < expectedSizes.size(); ++i) { QSizeF itemSize = layout->itemAt(i)->geometry().size(); QCOMPARE(itemSize, expectedSizes.at(i)); } @@ -2318,7 +2318,7 @@ void tst_QGraphicsGridLayout::alignment2() widget->setContentsMargins(0, 0, 0, 0); int i; - for (i = 0; i < itemDescriptions.count(); ++i) { + for (i = 0; i < itemDescriptions.size(); ++i) { ItemDesc desc = itemDescriptions.at(i); RectWidget *item = new RectWidget(widget); desc.apply(layout, item); @@ -2333,7 +2333,7 @@ void tst_QGraphicsGridLayout::alignment2() widget->resize(newSize); QApplication::sendPostedEvents(0, 0); - for (i = 0; i < expectedGeometries.count(); ++i) { + for (i = 0; i < expectedGeometries.size(); ++i) { QRectF itemRect = layout->itemAt(i)->geometry(); QCOMPARE(itemRect, expectedGeometries.at(i)); } @@ -2896,7 +2896,7 @@ void tst_QGraphicsGridLayout::geometries() widget->setContentsMargins(0, 0, 0, 0); int i; - for (i = 0; i < itemDescriptions.count(); ++i) { + for (i = 0; i < itemDescriptions.size(); ++i) { ItemDesc desc = itemDescriptions.at(i); RectWidget *item = new RectWidget(widget); desc.apply(layout, item); @@ -2911,7 +2911,7 @@ void tst_QGraphicsGridLayout::geometries() widget->resize(newSize); QApplication::processEvents(); - for (i = 0; i < expectedGeometries.count(); ++i) { + for (i = 0; i < expectedGeometries.size(); ++i) { QRectF itemRect = layout->itemAt(i)->geometry(); QCOMPARE(itemRect, expectedGeometries.at(i)); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index e848fa627d..709e384049 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2206,7 +2206,7 @@ void tst_QGraphicsItem::setTransform() scene.update(scene.sceneRect()); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); item.setTransform(QTransform().rotate(qreal(12.34))); QRectF rotatedRect = scene.sceneRect(); @@ -2214,14 +2214,14 @@ void tst_QGraphicsItem::setTransform() scene.update(scene.sceneRect()); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); item.setTransform(QTransform()); scene.update(scene.sceneRect()); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0)); QCOMPARE(rlist.size(), 2); @@ -5681,7 +5681,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape5() } const QList<QGraphicsItem *> children = parent->childItems(); - const int childrenCount = children.count(); + const int childrenCount = children.size(); for (int i = 0; i < 5; ++i) { QString clipString; @@ -8221,7 +8221,7 @@ void tst_QGraphicsItem::sorting() QVERIFY(QTest::qWaitForWindowActive(&view)); } QVERIFY(QTest::qWaitForWindowExposed(&view)); - QTRY_VERIFY(_paintedItems.count() > 0); + QTRY_VERIFY(_paintedItems.size() > 0); _paintedItems.clear(); @@ -11686,7 +11686,7 @@ public: QLatin1String wiseWords("AZ BUKI VEDI"); QString sentence(wiseWords); QStringList words = sentence.split(QLatin1Char(' '), Qt::SkipEmptyParts); - for (int i = 0; i < words.count(); ++i) { + for (int i = 0; i < words.size(); ++i) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); QLabel *label = new QLabel(words.at(i)); proxy->setWidget(label); diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index b5ba1d8787..a0bc43e150 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -670,7 +670,7 @@ public: private slots: void valueChanged(qreal value) { - for (int i = 0; i < fromGeoms.count(); ++i) { + for (int i = 0; i < fromGeoms.size(); ++i) { QGraphicsLayoutItem *li = itemAt(i); QRectF from = fromGeoms.at(i); QRectF to = toGeoms.at(i); @@ -825,7 +825,7 @@ CustomLayout(QGraphicsLayoutItem *parent) int count() const override { - return items.count(); + return items.size(); } QGraphicsLayoutItem* itemAt(int index) const override @@ -841,12 +841,12 @@ void removeAt(int index) override void addItem(QGraphicsLayoutItem *item) { - insertItem(items.count(), item); + insertItem(items.size(), item); } void insertItem(int index, QGraphicsLayoutItem *item) { - index = qBound(0, index, items.count()); + index = qBound(0, index, items.size()); item->setParentLayoutItem(this); @@ -854,7 +854,7 @@ void insertItem(int index, QGraphicsLayoutItem *item) updateParentWidget(widget); - if (index == items.count()) { + if (index == items.size()) { items.append(item); } else { items.insert(index, item); @@ -922,7 +922,7 @@ void tst_QGraphicsLayout::ownership() destructedSet.clear(); window->setLayout(0); - QCOMPARE(destructedSet.count(), 0); + QCOMPARE(destructedSet.size(), 0); delete window; } diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index ff625dbc00..e8fc027117 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -723,7 +723,7 @@ void tst_QGraphicsLinearLayout::orientation() // important to resize to preferredsize when orientation is switched widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); qApp->processEvents(); - for (i = 0; i < positions.count(); ++i) { + for (i = 0; i < positions.size(); ++i) { QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i)); if (initialOrientation == Qt::Horizontal) QCOMPARE(item->pos().y(), positions.at(i)); @@ -1121,7 +1121,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor() int i; - for (i = 0; i < stretches.count(); ++i) { + for (i = 0; i < stretches.size(); ++i) { QGraphicsWidget *item = new RectWidget(widget); item->setMinimumSize(5,5); item->setPreferredSize(10,5); @@ -1139,7 +1139,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor() qreal firstStretch = -1; qreal firstExtent = -1.; qreal sumExtent = 0; - for (i = 0; i < stretches.count(); ++i) { + for (i = 0; i < stretches.size(); ++i) { QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i)); qreal extent = item->size().width(); qreal stretch = (qreal)stretches.at(i); @@ -1297,7 +1297,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors() QSizeF itemSize = layout->itemAt(i)->geometry().size(); if (orientation == Qt::Vertical) itemSize.transpose(); - if (i < expectedSizes.count()) + if (i < expectedSizes.size()) QCOMPARE(itemSize.width(), qreal(expectedSizes.at(i))); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp index 849ac19d25..bade098023 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp @@ -41,28 +41,28 @@ void tst_QGraphicsObject::pos() QSignalSpy ySpy(&object, SIGNAL(yChanged())); QVERIFY(object.pos() == QPointF(0, 0)); object.setPos(10, 10); - QCOMPARE(xSpy.count(), 1); - QCOMPARE(ySpy.count(), 1); + QCOMPARE(xSpy.size(), 1); + QCOMPARE(ySpy.size(), 1); QCOMPARE(object.pos(), QPointF(10,10)); object.setPos(10, 10); - QCOMPARE(xSpy.count(), 1); - QCOMPARE(ySpy.count(), 1); + QCOMPARE(xSpy.size(), 1); + QCOMPARE(ySpy.size(), 1); object.setProperty("pos", QPointF(0, 0)); - QCOMPARE(xSpy.count(), 2); - QCOMPARE(ySpy.count(), 2); + QCOMPARE(xSpy.size(), 2); + QCOMPARE(ySpy.size(), 2); QCOMPARE(object.property("pos").toPointF(), QPointF(0,0)); object.setProperty("pos", QPointF(10, 0)); - QCOMPARE(xSpy.count(), 3); - QCOMPARE(ySpy.count(), 2); + QCOMPARE(xSpy.size(), 3); + QCOMPARE(ySpy.size(), 2); QCOMPARE(object.property("pos").toPointF(), QPointF(10,0)); object.setProperty("pos", QPointF(10, 10)); - QCOMPARE(xSpy.count(), 3); - QCOMPARE(ySpy.count(), 3); + QCOMPARE(xSpy.size(), 3); + QCOMPARE(ySpy.size(), 3); QVERIFY(object.property("pos") == QPointF(10, 10)); } @@ -73,19 +73,19 @@ void tst_QGraphicsObject::x() QSignalSpy ySpy(&object, SIGNAL(yChanged())); QVERIFY(object.pos() == QPointF(0, 0)); object.setX(10); - QCOMPARE(xSpy.count(), 1); - QCOMPARE(ySpy.count(), 0); + QCOMPARE(xSpy.size(), 1); + QCOMPARE(ySpy.size(), 0); QVERIFY(object.pos() == QPointF(10, 0)); QCOMPARE(object.x(), qreal(10)); object.setX(10); - QCOMPARE(xSpy.count(), 1); - QCOMPARE(ySpy.count(), 0); + QCOMPARE(xSpy.size(), 1); + QCOMPARE(ySpy.size(), 0); object.setProperty("x", 0); - QCOMPARE(xSpy.count(), 2); - QCOMPARE(ySpy.count(), 0); + QCOMPARE(xSpy.size(), 2); + QCOMPARE(ySpy.size(), 0); QCOMPARE(object.property("x").toDouble(), double(0)); } @@ -96,19 +96,19 @@ void tst_QGraphicsObject::y() QSignalSpy ySpy(&object, SIGNAL(yChanged())); QVERIFY(object.pos() == QPointF(0, 0)); object.setY(10); - QCOMPARE(xSpy.count(), 0); - QCOMPARE(ySpy.count(), 1); + QCOMPARE(xSpy.size(), 0); + QCOMPARE(ySpy.size(), 1); QVERIFY(object.pos() == QPointF(0, 10)); QCOMPARE(object.y(), qreal(10)); object.setY(10); - QCOMPARE(xSpy.count(), 0); - QCOMPARE(ySpy.count(), 1); + QCOMPARE(xSpy.size(), 0); + QCOMPARE(ySpy.size(), 1); object.setProperty("y", 0); - QCOMPARE(xSpy.count(), 0); - QCOMPARE(ySpy.count(), 2); + QCOMPARE(xSpy.size(), 0); + QCOMPARE(ySpy.size(), 2); QCOMPARE(object.property("y").toDouble(), qreal(0)); } @@ -118,15 +118,15 @@ void tst_QGraphicsObject::z() QSignalSpy zSpy(&object, SIGNAL(zChanged())); QCOMPARE(object.zValue(), qreal(0)); object.setZValue(10); - QCOMPARE(zSpy.count(), 1); + QCOMPARE(zSpy.size(), 1); QCOMPARE(object.zValue(), qreal(10)); object.setZValue(10); - QCOMPARE(zSpy.count(), 1); + QCOMPARE(zSpy.size(), 1); object.setProperty("z", 0); - QCOMPARE(zSpy.count(), 2); + QCOMPARE(zSpy.size(), 2); QCOMPARE(object.property("z").toDouble(), double(0)); } @@ -136,15 +136,15 @@ void tst_QGraphicsObject::opacity() QSignalSpy spy(&object, SIGNAL(opacityChanged())); QCOMPARE(object.opacity(), 1.); object.setOpacity(0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(object.opacity(), 0.); object.setOpacity(0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); object.setProperty("opacity", .5); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(object.property("opacity").toDouble(), .5); } @@ -154,15 +154,15 @@ void tst_QGraphicsObject::enabled() QSignalSpy spy(&object, SIGNAL(enabledChanged())); QVERIFY(object.isEnabled()); object.setEnabled(false); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!object.isEnabled()); object.setEnabled(false); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); object.setProperty("enabled", true); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(object.property("enabled").toBool()); } @@ -172,15 +172,15 @@ void tst_QGraphicsObject::visible() QSignalSpy spy(&object, SIGNAL(visibleChanged())); QVERIFY(object.isVisible()); object.setVisible(false); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!object.isVisible()); object.setVisible(false); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); object.setProperty("visible", true); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(object.property("visible").toBool()); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 4424a2b36a..088d2146e4 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -943,7 +943,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() proxy->setPos(50, 0); QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed); scene.addItem(proxy); - QTRY_VERIFY(sceneChangedSpy.count() > 0); + QTRY_VERIFY(sceneChangedSpy.size() > 0); // outside graphics item QTest::mouseMove(&view, QPoint(10, 10)); @@ -1041,9 +1041,9 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent() proxy->setFocus(); QTest::keyPress(view.viewport(), Qt::Key_Space); - QTRY_COMPARE(spy.count(), 0); + QTRY_COMPARE(spy.size(), 0); QTest::keyRelease(view.viewport(), Qt::Key_Space); - QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0); + QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0); } // protected void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) @@ -1071,7 +1071,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent() QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget*)&view); // wait for scene to be updated before doing any coordinate mappings on it - QTRY_VERIFY(sceneChangedSpy.count() > 0); + QTRY_VERIFY(sceneChangedSpy.size() > 0); QPoint pointInLineEdit = view.mapFromScene(proxy->mapToScene(15, proxy->boundingRect().center().y())); QTest::mousePress(view.viewport(), Qt::LeftButton, {}, pointInLineEdit); @@ -1112,13 +1112,13 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent() proxy->setFocus(); // wait for scene to be updated before doing any coordinate mappings on it - QTRY_VERIFY(sceneChangedSpy.count() > 0); + QTRY_VERIFY(sceneChangedSpy.size() > 0); QPoint buttonCenter = view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())); QTest::mousePress(view.viewport(), Qt::LeftButton, {}, buttonCenter); - QTRY_COMPARE(spy.count(), 0); + QTRY_COMPARE(spy.size(), 0); QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, buttonCenter); - QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0); + QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0); } void tst_QGraphicsProxyWidget::resizeEvent_data() @@ -1169,7 +1169,7 @@ void tst_QGraphicsProxyWidget::paintEvent() QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed); scene.addItem(&proxy); - QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready + QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready proxy.paintCount = 0; w->update(); @@ -2311,7 +2311,7 @@ void tst_QGraphicsProxyWidget::popup_basic() box->setGeometry(0, 0, 320, 40); box->addItems(QStringList() << "monday" << "tuesday" << "wednesday" << "thursday" << "saturday" << "sunday"); - QCOMPARE(proxy->childItems().count(), 0); + QCOMPARE(proxy->childItems().size(), 0); proxy->setWidget(boxGuard.release()); proxy->show(); scene.addItem(proxy); @@ -2328,7 +2328,7 @@ void tst_QGraphicsProxyWidget::popup_basic() QTRY_COMPARE(box->pos(), QPoint()); - QCOMPARE(proxy->childItems().count(), 1); + QCOMPARE(proxy->childItems().size(), 1); QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0]; QVERIFY(child->isWidget()); QVERIFY(child->widget()); @@ -2408,7 +2408,7 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() proxy->setWidget(widget); QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed); scene.addItem(proxy); - QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready + QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready // in QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); @@ -2626,7 +2626,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0); QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints); - QTRY_COMPARE(signalSpy.count(), 1); + QTRY_COMPARE(signalSpy.size(), 1); const QList<QVariant> arguments = signalSpy.takeFirst(); const QList<QRectF> updateRects = qvariant_cast<QList<QRectF> >(arguments.at(0)); QCOMPARE(updateRects.size(), 1); @@ -2901,10 +2901,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget() QTest::mousePress(view.viewport(), Qt::LeftButton, {}, view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8)))); - QTRY_COMPARE(spy.count(), 0); + QTRY_COMPARE(spy.size(), 0); QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8)))); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); @@ -3700,27 +3700,27 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation() // accepted by the embedded widget QCOMPARE(view.itemAt(wheelPosition), nullptr); wheelUp(Qt::NoScrollPhase); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); // wheeling on the label, which ignores the event, should scroll the view QCOMPARE(view.itemAt(wheelPosition), labelProxy); wheelUp(Qt::NoScrollPhase); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); QCOMPARE(view.itemAt(wheelPosition), labelProxy); wheelUp(Qt::NoScrollPhase); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); // left the widget QCOMPARE(view.itemAt(wheelPosition), nullptr); wheelUp(Qt::NoScrollPhase); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); // reached the nested widget, which accepts the wheel event, so no more scrolling QCOMPARE(view.itemAt(wheelPosition), nestedProxy); // remember this position for later const int scrollBarValueOnNestedProxy = view.verticalScrollBar()->value(); wheelUp(Qt::NoScrollPhase); - QCOMPARE(scrollSpy.count(), scrollCount); + QCOMPARE(scrollSpy.size(), scrollCount); QCOMPARE(nestedWidget->wheelEventCount, 1); // reset, try with kinetic events @@ -3731,41 +3731,41 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation() // no matter if the widget accepts wheel events - the view has the grab QCOMPARE(view.itemAt(wheelPosition), nullptr); wheelUp(Qt::ScrollBegin); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); for (int i = 0; i < 5; ++i) { wheelUp(Qt::ScrollUpdate); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); } wheelUp(Qt::ScrollEnd); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); // reset view.verticalScrollBar()->setValue(0); - scrollCount = scrollSpy.count(); + scrollCount = scrollSpy.size(); // starting a scroll on a widget that doesn't accept wheel events // should also scroll the view, which still gets the grab wheelUp(Qt::NoScrollPhase); - scrollCount = scrollSpy.count(); + scrollCount = scrollSpy.size(); QCOMPARE(view.itemAt(wheelPosition), labelProxy); wheelUp(Qt::ScrollBegin); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); for (int i = 0; i < 5; ++i) { wheelUp(Qt::ScrollUpdate); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); } wheelUp(Qt::ScrollEnd); - QCOMPARE(scrollSpy.count(), ++scrollCount); + QCOMPARE(scrollSpy.size(), ++scrollCount); // starting a scroll on a widget that does accept wheel events // should not scroll the view view.verticalScrollBar()->setValue(scrollBarValueOnNestedProxy); - scrollCount = scrollSpy.count(); + scrollCount = scrollSpy.size(); QCOMPARE(view.itemAt(wheelPosition), nestedProxy); wheelUp(Qt::ScrollBegin); - QCOMPARE(scrollSpy.count(), scrollCount); + QCOMPARE(scrollSpy.size(), scrollCount); } #endif // QT_CONFIG(wheelevent) @@ -3863,7 +3863,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation() QHash<int, QList<TouchRecord>> records; QWidget *mousePressReceiver = nullptr; - int count(int id = 0) const { return records.value(id).count(); } + int count(int id = 0) const { return records.value(id).size(); } TouchRecord at(int i, int id = 0) const { return records.value(id).at(i); } void clear() { @@ -3967,7 +3967,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation() QCOMPARE(record.receiver, view.windowHandle()); QCOMPARE(record.eventType, QEvent::TouchEnd); QCOMPARE(eventSpy.mousePressReceiver, pushButton1); - QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); eventSpy.clear(); clickedSpy.clear(); @@ -4035,7 +4035,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation() QCOMPARE(eventSpy.at(0, 3).receiver, touchWidget2); QCOMPARE(eventSpy.at(1, 3).receiver, touchWidget2); QCOMPARE(eventSpy.at(2, 3).receiver, touchWidget2); - QCOMPARE(clickedSpy.count(), 0); // multi-touch event does not synthesize a mouse event + QCOMPARE(clickedSpy.size(), 0); // multi-touch event does not synthesize a mouse event } QTEST_MAIN(tst_QGraphicsProxyWidget) diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 8389d8eab7..7ef8066ea1 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -319,27 +319,27 @@ void tst_QGraphicsScene::sceneRect() QGraphicsScene scene; QSignalSpy sceneRectChanged(&scene, &QGraphicsScene::sceneRectChanged); QCOMPARE(scene.sceneRect(), QRectF()); - QCOMPARE(sceneRectChanged.count(), 0); + QCOMPARE(sceneRectChanged.size(), 0); QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 10, 10)); item->setPen(QPen(Qt::black, 0)); item->setPos(-5, -5); - QCOMPARE(sceneRectChanged.count(), 0); + QCOMPARE(sceneRectChanged.size(), 0); QCOMPARE(itemAt(scene, 0, 0), item); QVERIFY(scene.items(QPointF(10, 10)).isEmpty()); - QCOMPARE(sceneRectChanged.count(), 0); + QCOMPARE(sceneRectChanged.size(), 0); QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 10, 10)); - QCOMPARE(sceneRectChanged.count(), 1); + QCOMPARE(sceneRectChanged.size(), 1); QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect()); item->setPos(0, 0); QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 15, 15)); - QCOMPARE(sceneRectChanged.count(), 2); + QCOMPARE(sceneRectChanged.size(), 2); QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect()); scene.setSceneRect(-100, -100, 10, 10); - QCOMPARE(sceneRectChanged.count(), 3); + QCOMPARE(sceneRectChanged.size(), 3); QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect()); QCOMPARE(itemAt(scene, 0, 0), item); @@ -347,16 +347,16 @@ void tst_QGraphicsScene::sceneRect() QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10)); item->setPos(10, 10); QCOMPARE(scene.sceneRect(), QRectF(-100, -100, 10, 10)); - QCOMPARE(sceneRectChanged.count(), 3); + QCOMPARE(sceneRectChanged.size(), 3); QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect()); scene.setSceneRect(QRectF()); QCOMPARE(itemAt(scene, 10, 10), item); QVERIFY(scene.items(QPointF(20, 20)).isEmpty()); - QCOMPARE(sceneRectChanged.count(), 4); + QCOMPARE(sceneRectChanged.size(), 4); QCOMPARE(scene.sceneRect(), QRectF(-5, -5, 25, 25)); - QCOMPARE(sceneRectChanged.count(), 5); + QCOMPARE(sceneRectChanged.size(), 5); QCOMPARE(sceneRectChanged.last().at(0).toRectF(), scene.sceneRect()); } @@ -944,32 +944,32 @@ void tst_QGraphicsScene::selectionChanged() { QGraphicsScene scene(0, 0, 1000, 1000); QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QPainterPath path; path.addRect(scene.sceneRect()); QCOMPARE(scene.selectionArea(), QPainterPath()); scene.setSelectionArea(path); QCOMPARE(scene.selectionArea(), path); - QCOMPARE(spy.count(), 0); // selection didn't change + QCOMPARE(spy.size(), 0); // selection didn't change QVERIFY(scene.selectedItems().isEmpty()); QGraphicsItem *rect = scene.addRect(QRectF(0, 0, 100, 100)); - QCOMPARE(spy.count(), 0); // selection didn't change + QCOMPARE(spy.size(), 0); // selection didn't change rect->setSelected(true); QVERIFY(!rect->isSelected()); - QCOMPARE(spy.count(), 0); // selection didn't change, item isn't selectable + QCOMPARE(spy.size(), 0); // selection didn't change, item isn't selectable rect->setFlag(QGraphicsItem::ItemIsSelectable); rect->setSelected(true); QVERIFY(rect->isSelected()); - QCOMPARE(spy.count(), 1); // selection changed + QCOMPARE(spy.size(), 1); // selection changed QCOMPARE(scene.selectedItems(), {rect}); rect->setSelected(false); QVERIFY(!rect->isSelected()); - QCOMPARE(spy.count(), 2); // selection changed + QCOMPARE(spy.size(), 2); // selection changed QVERIFY(scene.selectedItems().isEmpty()); QGraphicsEllipseItem *parentItem = new QGraphicsEllipseItem(QRectF(0, 0, 100, 100)); @@ -981,33 +981,33 @@ void tst_QGraphicsScene::selectionChanged() grandChildItem->setSelected(true); scene.addItem(parentItem); - QCOMPARE(spy.count(), 3); // the grandchild was added, so the selection changed once + QCOMPARE(spy.size(), 3); // the grandchild was added, so the selection changed once scene.removeItem(parentItem); - QCOMPARE(spy.count(), 4); // the grandchild was removed, so the selection changed + QCOMPARE(spy.size(), 4); // the grandchild was removed, so the selection changed rect->setSelected(true); - QCOMPARE(spy.count(), 5); // the rect was reselected, so the selection changed + QCOMPARE(spy.size(), 5); // the rect was reselected, so the selection changed scene.clearSelection(); - QCOMPARE(spy.count(), 6); // the scene selection was cleared + QCOMPARE(spy.size(), 6); // the scene selection was cleared rect->setSelected(true); - QCOMPARE(spy.count(), 7); // the rect was reselected, so the selection changed + QCOMPARE(spy.size(), 7); // the rect was reselected, so the selection changed rect->setFlag(QGraphicsItem::ItemIsSelectable, false); - QCOMPARE(spy.count(), 8); // the rect was unselected, so the selection changed + QCOMPARE(spy.size(), 8); // the rect was unselected, so the selection changed rect->setSelected(true); - QCOMPARE(spy.count(), 8); // the rect is not longer selectable, so the selection does not change + QCOMPARE(spy.size(), 8); // the rect is not longer selectable, so the selection does not change rect->setFlag(QGraphicsItem::ItemIsSelectable, true); rect->setSelected(true); - QCOMPARE(spy.count(), 9); // the rect is again selectable, so the selection changed + QCOMPARE(spy.size(), 9); // the rect is again selectable, so the selection changed delete rect; - QCOMPARE(spy.count(), 10); // a selected item was deleted; selection changed + QCOMPARE(spy.size(), 10); // a selected item was deleted; selection changed } void tst_QGraphicsScene::selectionChanged2() @@ -1020,7 +1020,7 @@ void tst_QGraphicsScene::selectionChanged2() item1->setFlag(QGraphicsItem::ItemIsSelectable); item2->setFlag(QGraphicsItem::ItemIsSelectable); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(50, 50)); @@ -1035,7 +1035,7 @@ void tst_QGraphicsScene::selectionChanged2() } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(150, 150)); @@ -1050,7 +1050,7 @@ void tst_QGraphicsScene::selectionChanged2() } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(50, 50)); @@ -1060,7 +1060,7 @@ void tst_QGraphicsScene::selectionChanged2() } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(50, 50)); @@ -1069,7 +1069,7 @@ void tst_QGraphicsScene::selectionChanged2() } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QGraphicsScene::addItem() @@ -2832,7 +2832,7 @@ void tst_QGraphicsScene::update() QCoreApplication::processEvents(); // Check that the update region is correct - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QRectF region; const auto &rects = qvariant_cast<QList<QRectF> >(spy.at(0).at(0)); for (const auto &rectF : rects) @@ -3531,7 +3531,7 @@ void tst_QGraphicsScene::task160653_selectionChanged() QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( view.viewport(), Qt::LeftButton, {}, view.mapFromScene(scene.items().first()->scenePos())); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QGraphicsScene::task250680_childClip() @@ -3662,8 +3662,8 @@ void tst_QGraphicsScene::insertionOrder() { QList<QGraphicsItem*> itemList = scene.items(); - QCOMPARE(itemList.count(), numItems); - for (int i = 0; i < itemList.count(); ++i) { + QCOMPARE(itemList.size(), numItems); + for (int i = 0; i < itemList.size(); ++i) { QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt()); } } @@ -3676,8 +3676,8 @@ void tst_QGraphicsScene::insertionOrder() { QList<QGraphicsItem*> itemList = scene.items(); - QCOMPARE(itemList.count(), numItems); - for (int i = 0; i < itemList.count(); ++i) { + QCOMPARE(itemList.size(), numItems); + for (int i = 0; i < itemList.size(); ++i) { QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt()); } } @@ -4025,7 +4025,7 @@ void tst_QGraphicsScene::polishItems2() // added 10 new children. These should be polished in the next // event loop iteration. const QList<QGraphicsItem *> children = item->childItems(); - QCOMPARE(children.count(), 10); + QCOMPARE(children.size(), 10); for (QGraphicsItem *child : children) QVERIFY(!static_cast<PolishItem *>(child)->polished); @@ -4604,13 +4604,13 @@ void tst_QGraphicsScene::zeroScale() rect1->setScale(0.00000001); QApplication::processEvents(); - QTRY_COMPARE(cl.changes.count(), 1); + QTRY_COMPARE(cl.changes.size(), 1); QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001); rect2->setScale(0.00000001); scene.addItem(rect2); rect1->setPos(20,20); QApplication::processEvents(); - QTRY_COMPARE(cl.changes.count(), 2); + QTRY_COMPARE(cl.changes.size(), 2); } void tst_QGraphicsScene::focusItemChangedSignal() @@ -4621,17 +4621,17 @@ void tst_QGraphicsScene::focusItemChangedSignal() QGraphicsScene scene; QSignalSpy spy(&scene, &QGraphicsScene::focusItemChanged); QVERIFY(spy.isValid()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); scene.setFocus(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QEvent activateEvent(QEvent::WindowActivate); QCoreApplication::sendEvent(&scene, &activateEvent); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem; topLevelItem1->setFlag(QGraphicsItem::ItemIsFocusable); scene.addItem(topLevelItem1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(!topLevelItem1->hasFocus()); QGraphicsRectItem *topLevelItem2 = new QGraphicsRectItem; @@ -4639,7 +4639,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() topLevelItem2->setFocus(); QVERIFY(!topLevelItem2->hasFocus()); scene.addItem(topLevelItem2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2); @@ -4648,7 +4648,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() QVERIFY(topLevelItem2->hasFocus()); scene.clearFocus(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), nullptr); @@ -4656,7 +4656,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason); scene.setFocus(Qt::MenuBarFocusReason); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2); @@ -4685,16 +4685,16 @@ void tst_QGraphicsScene::focusItemChangedSignal() QEvent deactivateEvent(QEvent::WindowDeactivate); QCoreApplication::sendEvent(&scene, &deactivateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCoreApplication::sendEvent(&scene, &activateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QGraphicsRectItem *panel1 = new QGraphicsRectItem; panel1->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable); panel1->setFocus(); scene.addItem(panel1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1); @@ -4704,11 +4704,11 @@ void tst_QGraphicsScene::focusItemChangedSignal() QGraphicsRectItem *panel2 = new QGraphicsRectItem; panel2->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable); scene.addItem(panel2); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); for (int i = 0; i < 3; ++i) { scene.setActivePanel(panel2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel2); @@ -4716,7 +4716,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason); scene.setActivePanel(panel1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1); @@ -4863,23 +4863,23 @@ void tst_QGraphicsScene::clearSelection() scene.addItem(regularRect); scene.addItem(selectedRect); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); - QCOMPARE(scene.selectedItems().count(), 2); + QCOMPARE(scene.selectedItems().size(), 2); scene.clearSelection(); QVERIFY(!regularRect->isSelected()); QVERIFY(selectedRect->isSelected()); - QCOMPARE(scene.selectedItems().count(), 1); - QCOMPARE(spy.count(), 3); + QCOMPARE(scene.selectedItems().size(), 1); + QCOMPARE(spy.size(), 3); delete regularRect; - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); scene.clearSelection(); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); delete selectedRect; - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.size(), 4); } void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache() diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 4cad9906bb..acfcde4798 100644 --- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -74,13 +74,13 @@ void tst_QGraphicsSceneIndex::scatteredItems() for (int i = 0; i < 10; ++i) scene.addRect(i*50, i*50, 40, 35); - QCOMPARE(scene.items(QPointF(5, 5)).count(), 1); - QCOMPARE(scene.items(QPointF(55, 55)).count(), 1); - QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0); + QCOMPARE(scene.items(QPointF(5, 5)).size(), 1); + QCOMPARE(scene.items(QPointF(55, 55)).size(), 1); + QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0); - QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).count(), 1); - QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 10); - QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0); + QCOMPARE(scene.items(QRectF(0, 0, 10, 10)).size(), 1); + QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 10); + QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0); } void tst_QGraphicsSceneIndex::overlappedItems_data() @@ -99,17 +99,17 @@ void tst_QGraphicsSceneIndex::overlappedItems() for (int j = 0; j < 10; ++j) scene.addRect(i*50, j*50, 200, 200)->setPen(QPen(Qt::black, 0)); - QCOMPARE(scene.items(QPointF(5, 5)).count(), 1); - QCOMPARE(scene.items(QPointF(55, 55)).count(), 4); - QCOMPARE(scene.items(QPointF(105, 105)).count(), 9); - QCOMPARE(scene.items(QPointF(-100, -100)).count(), 0); - - QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 100); - QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0); - QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).count(), 16); - QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).count(), 4); - QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).count(), 2); - QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).count(), 10); + QCOMPARE(scene.items(QPointF(5, 5)).size(), 1); + QCOMPARE(scene.items(QPointF(55, 55)).size(), 4); + QCOMPARE(scene.items(QPointF(105, 105)).size(), 9); + QCOMPARE(scene.items(QPointF(-100, -100)).size(), 0); + + QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 100); + QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).size(), 0); + QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).size(), 16); + QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).size(), 4); + QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).size(), 2); + QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).size(), 10); } void tst_QGraphicsSceneIndex::movingItems_data() @@ -128,20 +128,20 @@ void tst_QGraphicsSceneIndex::movingItems() scene.addRect(i*50, i*50, 40, 35); QGraphicsRectItem *box = scene.addRect(0, 0, 10, 10); - QCOMPARE(scene.items(QPointF(5, 5)).count(), 2); - QCOMPARE(scene.items(QPointF(-1, -1)).count(), 0); - QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).count(), 2); + QCOMPARE(scene.items(QPointF(5, 5)).size(), 2); + QCOMPARE(scene.items(QPointF(-1, -1)).size(), 0); + QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).size(), 2); box->setPos(10, 10); - QCOMPARE(scene.items(QPointF(9, 9)).count(), 1); - QCOMPARE(scene.items(QPointF(15, 15)).count(), 2); - QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 1); + QCOMPARE(scene.items(QPointF(9, 9)).size(), 1); + QCOMPARE(scene.items(QPointF(15, 15)).size(), 2); + QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 1); box->setPos(-5, -5); - QCOMPARE(scene.items(QPointF(-1, -1)).count(), 1); - QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 2); + QCOMPARE(scene.items(QPointF(-1, -1)).size(), 1); + QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).size(), 2); - QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 11); + QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).size(), 11); } void tst_QGraphicsSceneIndex::connectedToSceneRectChanged() diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index c3e2109b5a..e0f7286c22 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -665,16 +665,16 @@ void tst_QGraphicsView::openGLViewport() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QTRY_VERIFY(spy1.count() > 0); - QTRY_VERIFY(spy2.count() >= spy1.count()); + QTRY_VERIFY(spy1.size() > 0); + QTRY_VERIFY(spy2.size() >= spy1.size()); spy1.clear(); spy2.clear(); // Now test for resize (QTBUG-52419). This is special when the viewport is // a QOpenGLWidget since the underlying FBO must also be maintained. view.resize(300, 300); - QTRY_VERIFY(spy1.count() > 0); - QTRY_VERIFY(spy2.count() >= spy1.count()); + QTRY_VERIFY(spy1.size() > 0); + QTRY_VERIFY(spy2.size() >= spy1.size()); // There is no sane way to check if the framebuffer contents got updated // (grabFramebuffer is no good for the viewport case as that does not go // through paintGL). So skip the actual verification. @@ -1044,7 +1044,7 @@ void tst_QGraphicsView::rotated_rubberBand() sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton); sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()), Qt::LeftButton, Qt::LeftButton); - QCOMPARE(scene.selectedItems().count(), dim); + QCOMPARE(scene.selectedItems().size(), dim); foreach (const QGraphicsItem *item, scene.items()) { QCOMPARE(item->isSelected(), item->data(0).toBool()); } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 3df74038f3..053a0d4376 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -950,9 +950,9 @@ void tst_QGraphicsWidget::geometry() widget.setPos(pos); widget.resize(size); if (!size.isNull() && !pos.isNull()) - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); if (!size.isNull() && pos.isNull()) - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(widget.geometry(), QRectF(pos, size)); } @@ -963,10 +963,10 @@ void tst_QGraphicsWidget::geometryChanged() QCOMPARE(w.geometry(), QRectF(0, 0, 200, 200)); QSignalSpy spy(&w, SIGNAL(geometryChanged())); w.setGeometry(0, 0, 100, 100); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(w.geometry(), QRectF(0, 0, 100, 100)); w.setPos(10, 10); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(w.geometry(), QRectF(10, 10, 100, 100)); } @@ -978,10 +978,10 @@ void tst_QGraphicsWidget::width() QSignalSpy spy(&w, SIGNAL(widthChanged())); w.setProperty("width", qreal(50)); QCOMPARE(w.property("width").toReal(), qreal(50)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); //calling old school setGeometry should work too w.setGeometry(0, 0, 200, 200); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QGraphicsWidget::height() @@ -991,10 +991,10 @@ void tst_QGraphicsWidget::height() QSignalSpy spy(&w, SIGNAL(heightChanged())); w.setProperty("height", qreal(50)); QCOMPARE(w.property("height").toReal(), qreal(50)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); //calling old school setGeometry should work too w.setGeometry(0, 0, 200, 200); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QGraphicsWidget::getContentsMargins_data() @@ -1140,12 +1140,12 @@ void tst_QGraphicsWidget::layout() widget.setLayout(layout); QTRY_COMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout)); - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { SubQGraphicsWidget *item = children[i]; QCOMPARE(item->parentWidget(), (QGraphicsWidget *)&widget); QVERIFY(item->geometry() != QRectF(0, 0, -1, -1)); } - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // don't crash widget.setLayout(0); } @@ -1178,7 +1178,7 @@ void tst_QGraphicsWidget::layoutDirection() QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), true); view->show(); QVERIFY(QTest::qWaitForWindowExposed(view.data())); - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QTRY_COMPARE(children[i]->layoutDirection(), layoutDirection); QTRY_COMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false); view->update(); @@ -1416,7 +1416,7 @@ void tst_QGraphicsWidget::setTabOrder() QVERIFY(view.viewport()->hasFocus()); int currentItem = 0; - while (currentItem < children.count() - 1) { + while (currentItem < children.size() - 1) { QTest::keyPress(view.viewport(), Qt::Key_Tab); ++currentItem; QVERIFY(children[currentItem % children.size()]->hasFocus()); @@ -1565,7 +1565,7 @@ void tst_QGraphicsWidget::unsetLayoutDirection() widget.setLayoutDirection(layoutDirection); widget.unsetLayoutDirection(); QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), false); - for (int i = 0; i < children.count(); ++i) { + for (int i = 0; i < children.size(); ++i) { QCOMPARE(children[i]->layoutDirection(), Qt::LeftToRight); } } @@ -1927,7 +1927,7 @@ void tst_QGraphicsWidget::setSizes() QSizeF max = QSizeF(50, 50); int i; - for (i = 0; i < inputInstructions.count(); ++i) { + for (i = 0; i < inputInstructions.size(); ++i) { Inst input = inputInstructions.at(i); // defaults @@ -1981,7 +1981,7 @@ void tst_QGraphicsWidget::setSizes() widget->setPreferredSize(pref); widget->setMaximumSize(max); - for (i = 0; i < compareInstructions.count(); ++i) { + for (i = 0; i < compareInstructions.size(); ++i) { Inst input = compareInstructions.at(i); switch (input.first) { case MinimumSize: @@ -2731,11 +2731,11 @@ void tst_QGraphicsWidget::task250119_shortcutContext() w_signal.setFocus(); QTest::keyPress(&view, Qt::Key_B); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); w_signal.clearFocus(); QTest::keyPress(&view, Qt::Key_B); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); scene.removeItem(&w_signal); } diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 1008d8dcc0..da68efadbb 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -424,12 +424,12 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view) QVERIFY(spy.isValid()); view->setIconSize(QSize(32, 32)); QCOMPARE(view->iconSize(), QSize(32, 32)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).value<QSize>(), QSize(32, 32)); // Should this happen? view->setIconSize(QSize(-1, -1)); QCOMPARE(view->iconSize(), QSize(-1, -1)); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(view->currentIndex(), QModelIndex()); QCOMPARE(view->rootIndex(), QModelIndex()); @@ -663,9 +663,9 @@ void tst_QAbstractItemView::selectAll() GeometriesTestView view; view.setModel(&model); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); view.selectAll(); - QCOMPARE(view.selectedIndexes().count(), 4 * 4); + QCOMPARE(view.selectedIndexes().size(), 4 * 4); } void tst_QAbstractItemView::ctrlA() @@ -674,9 +674,9 @@ void tst_QAbstractItemView::ctrlA() GeometriesTestView view; view.setModel(&model); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier); - QCOMPARE(view.selectedIndexes().count(), 4 * 4); + QCOMPARE(view.selectedIndexes().size(), 4 * 4); } void tst_QAbstractItemView::persistentEditorFocus() @@ -693,7 +693,7 @@ void tst_QAbstractItemView::persistentEditorFocus() //these are spinboxes because we put numbers inside const QList<QSpinBox*> list = view.viewport()->findChildren<QSpinBox*>(); - QCOMPARE(list.count(), 2); //these should be the 2 editors + QCOMPARE(list.size(), 2); //these should be the 2 editors view.setCurrentIndex(model.index(0, 0)); QCOMPARE(view.currentIndex(), model.index(0, 0)); @@ -1354,7 +1354,7 @@ void tst_QAbstractItemView::task200665_itemEntered() QSignalSpy spy(&view, &QAbstractItemView::entered); view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); } void tst_QAbstractItemView::task257481_emptyEditor() @@ -1377,17 +1377,17 @@ void tst_QAbstractItemView::task257481_emptyEditor() treeView.edit(model.index(0, 0)); QList<QLineEdit *> lineEditors = treeView.viewport()->findChildren<QLineEdit *>(); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QVERIFY(!lineEditors.constFirst()->size().isEmpty()); treeView.edit(model.index(1, 0)); lineEditors = treeView.viewport()->findChildren<QLineEdit *>(); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QVERIFY(!lineEditors.constFirst()->size().isEmpty()); treeView.edit(model.index(2, 0)); lineEditors = treeView.viewport()->findChildren<QLineEdit *>(); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QVERIFY(!lineEditors.constFirst()->size().isEmpty()); } @@ -1421,7 +1421,7 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling() QCOMPARE(view.currentIndex(), index1); QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(index0)); QVERIFY(selected.contains(index1)); } @@ -1475,7 +1475,7 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection() // Verify that the selection worked OK QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(index1)); QVERIFY(selected.contains(index2)); @@ -1498,7 +1498,7 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection() // Verify that the selection worked OK selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(index1)); QVERIFY(selected.contains(index2)); } @@ -1527,7 +1527,7 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() // Select item 1 view.setCurrentIndex(index1); QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(index1)); // Now press control and draw a rubberband around items 1 and 2. @@ -1544,7 +1544,7 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() // Verify that item 2 is selected now selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(index2)); } @@ -1577,21 +1577,21 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection() QVERIFY(view.viewport()->rect().contains(p)); QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, p); QCOMPARE(view.currentIndex(), index49); - QCOMPARE(view.selectedItems().count(), 1); + QCOMPARE(view.selectedItems().size(), 1); QModelIndex index47 = view.model()->index(47,0); p = view.visualRect(index47).center(); QVERIFY(view.viewport()->rect().contains(p)); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); QCOMPARE(view.currentIndex(), index47); - QCOMPARE(view.selectedItems().count(), 3); //49, 48, 47; + QCOMPARE(view.selectedItems().size(), 3); //49, 48, 47; QModelIndex index44 = view.model()->index(44,0); p = view.visualRect(index44).center(); QVERIFY(view.viewport()->rect().contains(p)); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); QCOMPARE(view.currentIndex(), index44); - QCOMPARE(view.selectedItems().count(), 6); //49 .. 44; + QCOMPARE(view.selectedItems().size(), 6); //49 .. 44; } @@ -1616,7 +1616,7 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection() QTest::mouseMove(table.viewport(), itemRect.center()); QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center()); - QCOMPARE(table.selectedItems().count(), 1); + QCOMPARE(table.selectedItems().size(), 1); QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column())); } @@ -1653,12 +1653,12 @@ void tst_QAbstractItemView::testClickedSignal() QSignalSpy clickedSpy(&view, &QTableWidget::clicked); QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, p); - QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); QTest::mouseClick(view.viewport(), Qt::RightButton, {}, p); // We expect that right-clicks do not cause the clicked() signal to // be emitted. - QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); } @@ -1722,28 +1722,28 @@ void tst_QAbstractItemView::deselectInSingleSelection() QPoint clickpos = rect22.center(); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, clickpos); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0); // second click with modifier however does select QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); // keyboard QTest::keyClick(&view, Qt::Key_Space, Qt::NoModifier); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0); // second keypress with modifier however does select QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier); QCOMPARE(view.currentIndex(), index22); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); } void tst_QAbstractItemView::testNoActivateOnDisabledItem() @@ -1771,7 +1771,7 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem() QPoint clickPos = treeView.visualRect(itemIndex).center(); QTest::mouseClick(treeView.viewport(), Qt::LeftButton, {}, clickPos); - QCOMPARE(activatedSpy.count(), 0); + QCOMPARE(activatedSpy.size(), 0); } void tst_QAbstractItemView::testFocusPolicy_data() @@ -1865,7 +1865,7 @@ void tst_QAbstractItemView::QTBUG31411_noSelection() QVERIFY(editor2); QTest::keyClick(editor2, Qt::Key_Escape, Qt::NoModifier); - QCOMPARE(selectionChangeSpy.count(), 0); + QCOMPARE(selectionChangeSpy.size(), 0); } void tst_QAbstractItemView::QTBUG39324_settingSameInstanceOfIndexWidget() @@ -1907,7 +1907,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Click "C" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexC).center()); QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(indexC)); // Insert new item "B1" @@ -1917,14 +1917,14 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Shift-click "D" -> we expect that "C" and "D" are selected QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexD).center()); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(indexC)); QVERIFY(selected.contains(indexD)); // Click "D" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexD).center()); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(indexD)); // Remove items "B" and "C" @@ -1936,7 +1936,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Shift-click "F" -> we expect that "D", "E", and "F" are selected QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexF).center()); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 3); + QCOMPARE(selected.size(), 3); QVERIFY(selected.contains(indexD)); QVERIFY(selected.contains(indexE)); QVERIFY(selected.contains(indexF)); @@ -1945,7 +1945,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() while (view.currentIndex() != indexA) QTest::keyClick(&view, Qt::Key_Up); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(indexA)); // Change the sort order @@ -1954,7 +1954,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Shift-click "F" -> All items should be selected QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, view.visualRect(indexF).center()); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), model.rowCount()); + QCOMPARE(selected.size(), model.rowCount()); // Restore the old sort order proxyModel.sort(0, Qt::AscendingOrder); @@ -1962,7 +1962,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Click "D" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexD).center()); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(indexD)); // Insert new item "B2" @@ -1972,7 +1972,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Press Shift+Down -> "D" and "E" should be selected. QTest::keyClick(&view, Qt::Key_Down, Qt::ShiftModifier); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(indexD)); QVERIFY(selected.contains(indexE)); @@ -1981,7 +1981,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexA).center()); view.setCurrentIndex(indexD); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 1); + QCOMPARE(selected.size(), 1); QVERIFY(selected.contains(indexD)); // Insert new item "B3" @@ -1991,7 +1991,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents() // Press Shift+Down -> "D" and "E" should be selected. QTest::keyClick(&view, Qt::Key_Down, Qt::ShiftModifier); selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 2); + QCOMPARE(selected.size(), 2); QVERIFY(selected.contains(indexD)); QVERIFY(selected.contains(indexE)); } @@ -2269,14 +2269,14 @@ void tst_QAbstractItemView::testClickToSelect() // Click the center of the visualRect of item "A" QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, centerA); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.back().front().value<QRect>(), QRect(centerA, QSize(1, 1))); // Click a point slightly away from the center const QPoint nearCenterA = centerA + QPoint(1, 1); QVERIFY(visualRectA.contains(nearCenterA)); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, nearCenterA); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(spy.back().front().value<QRect>(), QRect(nearCenterA, QSize(1, 1))); } @@ -2634,7 +2634,7 @@ void tst_QAbstractItemView::dragSelectAfterNewPress() // Verify that the selection worked OK QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 3); + QCOMPARE(selected.size(), 3); for (int i = 0; i < 2; ++i) QVERIFY(selected.contains(model.index(i, 0))); @@ -2651,7 +2651,7 @@ void tst_QAbstractItemView::dragSelectAfterNewPress() // Verify that the selection worked OK selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 6); + QCOMPARE(selected.size(), 6); for (int i = 0; i < 5; ++i) QVERIFY(selected.contains(model.index(i, 0))); } @@ -3327,7 +3327,7 @@ void tst_QAbstractItemView::selectionAutoScrolling() QTRY_COMPARE(scrollBar->value(), 0); else QTRY_COMPARE(scrollBar->value(), scrollBar->maximum()); - QVERIFY(listview.selectionModel()->selectedIndexes().count() > 0); + QVERIFY(listview.selectionModel()->selectedIndexes().size() > 0); QTest::mouseRelease(listview.viewport(), Qt::LeftButton, Qt::NoModifier, dragPoint); } diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index 9c37e0af6d..8bdbc08467 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -497,11 +497,11 @@ void tst_QColumnView::selectAll() view.setModel(&m_fakeDirModel); view.selectAll(); - QVERIFY(view.selectionModel()->selectedIndexes().count() >= 0); + QVERIFY(view.selectionModel()->selectedIndexes().size() >= 0); view.setCurrentIndex(m_fakeDirHomeIndex); view.selectAll(); - QVERIFY(view.selectionModel()->selectedIndexes().count() > 0); + QVERIFY(view.selectionModel()->selectedIndexes().size() > 0); QModelIndex file; for (int i = 0; i < m_fakeDirModel.rowCount(m_fakeDirHomeIndex); ++i) { @@ -512,10 +512,10 @@ void tst_QColumnView::selectAll() } view.setCurrentIndex(file); view.selectAll(); - QVERIFY(view.selectionModel()->selectedIndexes().count() > 0); + QVERIFY(view.selectionModel()->selectedIndexes().size() > 0); view.setCurrentIndex(QModelIndex()); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0); } void tst_QColumnView::clicked() @@ -536,13 +536,13 @@ void tst_QColumnView::clicked() QPoint localPoint = view.visualRect(m_fakeDirHomeIndex).center(); QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, localPoint); - QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); QCoreApplication::processEvents(); if (sizeof(qreal) != sizeof(double)) QSKIP("Skipped due to rounding errors"); - for (int i = 0; i < view.createdColumns.count(); ++i) { + for (int i = 0; i < view.createdColumns.size(); ++i) { QAbstractItemView *column = view.createdColumns.at(i); if (column && column->selectionModel() && (column->rootIndex() == m_fakeDirHomeIndex)) QVERIFY(column->selectionModel()->selectedIndexes().isEmpty()); @@ -560,7 +560,7 @@ void tst_QColumnView::selectedColumns() QTest::qWait(ANIMATION_DELAY); - for (int i = 0; i < view.createdColumns.count(); ++i) { + for (int i = 0; i < view.createdColumns.size(); ++i) { QAbstractItemView *column = view.createdColumns.at(i); if (!column) continue; @@ -591,7 +591,7 @@ void tst_QColumnView::setSelectionModel() view.setSelectionModel(selectionModel); bool found = false; - for (int i = 0; i < view.createdColumns.count(); ++i) { + for (int i = 0; i < view.createdColumns.size(); ++i) { if (view.createdColumns.at(i)->selectionModel() == selectionModel) { found = true; break; @@ -631,7 +631,7 @@ void tst_QColumnView::moveGrip_basic() view.setMinimumWidth(200); grip->moveGrip(-800); QCOMPARE(view.width(), 200); - QCOMPARE(spy.count(), 5); + QCOMPARE(spy.size(), 5); } void tst_QColumnView::moveGrip_data() @@ -659,7 +659,7 @@ void tst_QColumnView::moveGrip() topLevel.show(); QVERIFY(QTest::qWaitForWindowActive(&topLevel)); - int columnNum = view.createdColumns.count() - 2; + int columnNum = view.createdColumns.size() - 2; QVERIFY(columnNum >= 0); const QObjectList list = view.createdColumns[columnNum]->children(); QColumnViewGrip *grip = nullptr; @@ -687,7 +687,7 @@ void tst_QColumnView::doubleClick() QCOMPARE(view.width(), 200); QTest::mouseDClick(grip, Qt::LeftButton); QCOMPARE(view.width(), view.sizeHint().width()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QColumnView::gripMoved() @@ -711,7 +711,7 @@ void tst_QColumnView::gripMoved() QCoreApplication::processEvents(); QTest::mouseRelease(grip, Qt::LeftButton); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(view.width(), oldWidth + 65); } @@ -776,7 +776,7 @@ void tst_QColumnView::setPreviewWidget() void tst_QColumnView::sizes() { QColumnView view; - QCOMPARE(view.columnWidths().count(), 0); + QCOMPARE(view.columnWidths().size(), 0); const QList<int> newSizes{ 10, 4, 50, 6 }; @@ -787,16 +787,16 @@ void tst_QColumnView::sizes() view.setModel(&m_fakeDirModel); view.setCurrentIndex(m_fakeDirHomeIndex); - QList<int> postSizes = view.columnWidths().mid(0, newSizes.count()); - QCOMPARE(postSizes, newSizes.mid(0, postSizes.count())); + QList<int> postSizes = view.columnWidths().mid(0, newSizes.size()); + QCOMPARE(postSizes, newSizes.mid(0, postSizes.size())); - QVERIFY(view.columnWidths().count() > 1); + QVERIFY(view.columnWidths().size() > 1); QList<int> smallerSizes{ 6 }; view.setColumnWidths(smallerSizes); QList<int> expectedSizes = newSizes; expectedSizes[0] = 6; - postSizes = view.columnWidths().mid(0, newSizes.count()); - QCOMPARE(postSizes, expectedSizes.mid(0, postSizes.count())); + postSizes = view.columnWidths().mid(0, newSizes.size()); + QCOMPARE(postSizes, expectedSizes.mid(0, postSizes.size())); } void tst_QColumnView::rowDelegate() @@ -806,7 +806,7 @@ void tst_QColumnView::rowDelegate() view.setItemDelegateForRow(3, d); view.setModel(&m_fakeDirModel); - for (int i = 0; i < view.createdColumns.count(); ++i) { + for (int i = 0; i < view.createdColumns.size(); ++i) { QAbstractItemView *column = view.createdColumns.at(i); QCOMPARE(column->itemDelegateForRow(3), d); } @@ -956,7 +956,7 @@ void tst_QColumnView::dynamicModelChanges() model.appendRow(item); QVERIFY(QTest::qWaitForWindowExposed(&view)); //let the time for painting to occur - QTRY_COMPARE(delegate.paintedIndexes.count(), 1); + QTRY_COMPARE(delegate.paintedIndexes.size(), 1); QCOMPARE(*delegate.paintedIndexes.begin(), model.index(0,0)); } diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp index 41db835f0f..c95d179542 100644 --- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp +++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp @@ -252,22 +252,22 @@ void tst_QDataWidgetMapper::currentIndexChanged() QSignalSpy spy(&mapper, &QDataWidgetMapper::currentIndexChanged); mapper.toFirst(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 0); mapper.toNext(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 1); mapper.setCurrentIndex(7); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 7); mapper.setCurrentIndex(-1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); mapper.setCurrentIndex(42); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QDataWidgetMapper::changingValues() @@ -424,21 +424,21 @@ void tst_QDataWidgetMapper::textEditDoesntChangeFocusOnTab_qtbug3305() int closeEditorSpyCount = 0; const QString textEditContents = textEdit->toPlainText(); - QCOMPARE(closeEditorSpy.count(), closeEditorSpyCount); + QCOMPARE(closeEditorSpy.size(), closeEditorSpyCount); QVERIFY(lineEdit->hasFocus()); QVERIFY(!textEdit->hasFocus()); // this will generate a closeEditor for the tab key, and another for the focus out QTest::keyClick(QApplication::focusWidget(), Qt::Key_Tab); closeEditorSpyCount += 2; - QTRY_COMPARE(closeEditorSpy.count(), closeEditorSpyCount); + QTRY_COMPARE(closeEditorSpy.size(), closeEditorSpyCount); QTRY_VERIFY(textEdit->hasFocus()); QVERIFY(!lineEdit->hasFocus()); // now that the text edit is focused, a tab keypress will insert a tab, not change focus QTest::keyClick(QApplication::focusWidget(), Qt::Key_Tab); - QTRY_COMPARE(closeEditorSpy.count(), closeEditorSpyCount); + QTRY_COMPARE(closeEditorSpy.size(), closeEditorSpyCount); QVERIFY(!lineEdit->hasFocus()); QVERIFY(textEdit->hasFocus()); @@ -449,7 +449,7 @@ void tst_QDataWidgetMapper::textEditDoesntChangeFocusOnTab_qtbug3305() QTRY_VERIFY(lineEdit->hasFocus()); QVERIFY(!textEdit->hasFocus()); ++closeEditorSpyCount; - QCOMPARE(closeEditorSpy.count(), closeEditorSpyCount); + QCOMPARE(closeEditorSpy.size(), closeEditorSpyCount); } QTEST_MAIN(tst_QDataWidgetMapper) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 93f991b0fe..a0aeb0cc12 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -474,7 +474,7 @@ void tst_QHeaderView::init() QSignalSpy spy(view, &QHeaderView::sectionCountChanged); view->setModel(model); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); view->resize(200,200); } @@ -795,10 +795,10 @@ void tst_QHeaderView::visualIndexAt() for (int i : hidden) view->setSectionHidden(i, true); - for (int j = 0; j < from.count(); ++j) + for (int j = 0; j < from.size(); ++j) view->moveSection(from.at(j), to.at(j)); - for (int k = 0; k < coordinate.count(); ++k) + for (int k = 0; k < coordinate.size(); ++k) QTRY_COMPARE(view->visualIndexAt(coordinate.at(k)), visual.at(k)); } @@ -910,14 +910,14 @@ void tst_QHeaderView::swapSections() QCOMPARE(view->sectionsMoved(), true); for (int i = 0; i < view->count(); ++i) QCOMPARE(view->logicalIndex(i), logical.at(i)); - QCOMPARE(spy1.count(), 4); + QCOMPARE(spy1.size(), 4); logical = { 3, 1, 2, 0 }; view->swapSections(3, 0); QCOMPARE(view->sectionsMoved(), true); for (int j = 0; j < view->count(); ++j) QCOMPARE(view->logicalIndex(j), logical.at(j)); - QCOMPARE(spy1.count(), 6); + QCOMPARE(spy1.size(), 6); } void tst_QHeaderView::moveSection_data() @@ -963,9 +963,9 @@ void tst_QHeaderView::moveSection() QFETCH(const IntList, logical); QFETCH(int, count); - QCOMPARE(from.count(), to.count()); - QCOMPARE(from.count(), moved.count()); - QCOMPARE(view->count(), logical.count()); + QCOMPARE(from.size(), to.size()); + QCOMPARE(from.size(), moved.size()); + QCOMPARE(view->count(), logical.size()); QSignalSpy spy1(view, &QHeaderView::sectionMoved); QCOMPARE(view->sectionsMoved(), false); @@ -973,7 +973,7 @@ void tst_QHeaderView::moveSection() for (int h : hidden) view->setSectionHidden(h, true); - for (int i = 0; i < from.count(); ++i) { + for (int i = 0; i < from.size(); ++i) { view->moveSection(from.at(i), to.at(i)); QCOMPARE(view->sectionsMoved(), moved.at(i)); } @@ -981,7 +981,7 @@ void tst_QHeaderView::moveSection() for (int j = 0; j < view->count(); ++j) QCOMPARE(view->logicalIndex(j), logical.at(j)); - QCOMPARE(spy1.count(), count); + QCOMPARE(spy1.size(), count); } void tst_QHeaderView::resizeAndMoveSection_data() @@ -1166,14 +1166,14 @@ void tst_QHeaderView::resizeWithResizeModes() QFETCH(const IntList, expected); view->setStretchLastSection(false); - for (int i = 0; i < sections.count(); ++i) { + for (int i = 0; i < sections.size(); ++i) { view->resizeSection(i, sections.at(i)); view->setSectionResizeMode(i, modes.at(i)); } topLevel->show(); QVERIFY(QTest::qWaitForWindowExposed(topLevel)); view->resize(size, size); - for (int j = 0; j < expected.count(); ++j) + for (int j = 0; j < expected.size(); ++j) QCOMPARE(view->sectionSize(j), expected.at(j)); } @@ -1200,7 +1200,7 @@ void tst_QHeaderView::moveAndInsertSection() view->moveSection(from, to); model->insertRow(insert); - for (int i = 0; i < mapping.count(); ++i) + for (int i = 0; i < mapping.size(); ++i) QCOMPARE(view->logicalIndex(i), mapping.at(i)); } @@ -1271,21 +1271,21 @@ void tst_QHeaderView::resizeSection() view->setSectionsMovable(true); view->setStretchLastSection(false); - for (int i = 0; i < logical.count(); ++i) + for (int i = 0; i < logical.size(); ++i) if (logical.at(i) > -1 && logical.at(i) < view->count()) // for now view->setSectionResizeMode(logical.at(i), mode.at(i)); - for (int j = 0; j < logical.count(); ++j) + for (int j = 0; j < logical.size(); ++j) view->resizeSection(logical.at(j), initial); QSignalSpy spy(view, &QHeaderView::sectionResized); - for (int k = 0; k < logical.count(); ++k) + for (int k = 0; k < logical.size(); ++k) view->resizeSection(logical.at(k), size.at(k)); - QCOMPARE(spy.count(), resized); + QCOMPARE(spy.size(), resized); - for (int l = 0; l < logical.count(); ++l) + for (int l = 0; l < logical.size(); ++l) QCOMPARE(view->sectionSize(logical.at(l)), expected.at(l)); } @@ -1338,19 +1338,19 @@ void tst_QHeaderView::clearSectionSorting() QSignalSpy sectionClickedSpy(&h, &QHeaderView::sectionClicked); QVERIFY(sectionClickedSpy.isValid()); - QCOMPARE(sectionClickedSpy.count(), 0); + QCOMPARE(sectionClickedSpy.size(), 0); QSignalSpy sortIndicatorChangedSpy(&h, &QHeaderView::sortIndicatorChanged); QVERIFY(sortIndicatorChangedSpy.isValid()); - QCOMPARE(sortIndicatorChangedSpy.count(), 0); + QCOMPARE(sortIndicatorChangedSpy.size(), 0); enum { Count = 30 }; // normal behavior: clicking multiple times will just toggle the sort indicator for (int i = 0; i < Count; ++i) { QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(sectionClickedSpy.count(), i + 1); - QCOMPARE(sortIndicatorChangedSpy.count(), i + 1); + QCOMPARE(sectionClickedSpy.size(), i + 1); + QCOMPARE(sortIndicatorChangedSpy.size(), i + 1); QCOMPARE(h.sortIndicatorSection(), 0); const auto expectedOrder = (i % 2) == 0 ? Qt::AscendingOrder : Qt::DescendingOrder; QCOMPARE(h.sortIndicatorOrder(), expectedOrder); @@ -1367,8 +1367,8 @@ void tst_QHeaderView::clearSectionSorting() // clearing behavior: clicking multiple times will be tristate (asc, desc, nothing) for (int i = 0; i < Count; ++i) { QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(sectionClickedSpy.count(), i + 1); - QCOMPARE(sortIndicatorChangedSpy.count(), i + 1); + QCOMPARE(sectionClickedSpy.size(), i + 1); + QCOMPARE(sortIndicatorChangedSpy.size(), i + 1); switch (i % 3) { case 0: QCOMPARE(h.sortIndicatorSection(), 0); @@ -1736,7 +1736,7 @@ static void saveRestoreImpl(const QByteArray &state, SaveRestoreOption option) h2.setModel(&m); QVERIFY(h2.restoreState(state)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), 2); QCOMPARE(h2.logicalIndex(0), 2); @@ -2040,9 +2040,9 @@ void tst_QHeaderView::sectionPressedSignal() QSignalSpy spy(&h, &QHeaderView::sectionPressed); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QTest::mousePress(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(spy.count(), count); + QCOMPARE(spy.size(), count); } void tst_QHeaderView::sectionClickedSignal() @@ -2062,19 +2062,19 @@ void tst_QHeaderView::sectionClickedSignal() QSignalSpy spy(&h, &QHeaderView::sectionClicked); QSignalSpy spy2(&h, &QHeaderView::sortIndicatorChanged); - QCOMPARE(spy.count(), 0); - QCOMPARE(spy2.count(), 0); + QCOMPARE(spy.size(), 0); + QCOMPARE(spy2.size(), 0); QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(spy.count(), count); - QCOMPARE(spy2.count(), count); + QCOMPARE(spy.size(), count); + QCOMPARE(spy2.size(), count); //now let's try with the sort indicator hidden (the result should be the same spy.clear(); spy2.clear(); h.setSortIndicatorShown(false); QTest::mouseClick(h.viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); - QCOMPARE(spy.count(), count); - QCOMPARE(spy2.count(), count); + QCOMPARE(spy.size(), count); + QCOMPARE(spy2.size(), count); } void tst_QHeaderView::defaultSectionSize_data() @@ -2255,7 +2255,7 @@ void tst_QHeaderView::task236450_hidden() for (int i : hide1) view.hideSection(i); - QCOMPARE(view.hiddenSectionCount(), hide1.count()); + QCOMPARE(view.hiddenSectionCount(), hide1.size()); for (int i = 0; i < 6; i++) QCOMPARE(!view.isSectionHidden(i), !hide1.contains(i)); @@ -2263,13 +2263,13 @@ void tst_QHeaderView::task236450_hidden() view.scheduleDelayedItemsLayout(); view.executeDelayedItemsLayout(); //force to do a relayout - QCOMPARE(view.hiddenSectionCount(), hide1.count()); + QCOMPARE(view.hiddenSectionCount(), hide1.size()); for (int i = 0; i < 6; i++) { QCOMPARE(!view.isSectionHidden(i), !hide1.contains(i)); view.setSectionHidden(i, hide2.contains(i)); } - QCOMPARE(view.hiddenSectionCount(), hide2.count()); + QCOMPARE(view.hiddenSectionCount(), hide2.size()); for (int i = 0; i < 6; i++) QCOMPARE(!view.isSectionHidden(i), !hide2.contains(i)); } @@ -2301,10 +2301,10 @@ void tst_QHeaderView::task248050_hideRow() //returns 0 if everything is fine. static int checkHeaderViewOrder(const QHeaderView *view, const IntList &expected) { - if (view->count() != expected.count()) + if (view->count() != expected.size()) return 1; - for (int i = 0; i < expected.count(); i++) { + for (int i = 0; i < expected.size(); i++) { if (view->logicalIndex(i) != expected.at(i)) return i + 10; if (view->visualIndex(expected.at(i)) != i) @@ -2395,8 +2395,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked() QTest::mouseClick(tv.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(tv.horizontalHeader()->sectionViewportPosition(11) + tv.horizontalHeader()->sectionSize(11) / 2, 5)); - QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); + QCOMPARE(pressedSpy.size(), 1); QCOMPARE(clickedSpy.at(0).at(0).toInt(), 11); QCOMPARE(pressedSpy.at(0).at(0).toInt(), 11); @@ -2404,8 +2404,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked() QPoint(tv.horizontalHeader()->sectionViewportPosition(8) + tv.horizontalHeader()->sectionSize(0) / 2, 5)); - QCOMPARE(clickedSpy.count(), 2); - QCOMPARE(pressedSpy.count(), 2); + QCOMPARE(clickedSpy.size(), 2); + QCOMPARE(pressedSpy.size(), 2); QCOMPARE(clickedSpy.at(1).at(0).toInt(), 8); QCOMPARE(pressedSpy.at(1).at(0).toInt(), 8); @@ -2413,8 +2413,8 @@ void tst_QHeaderView::QTBUG7833_sectionClicked() QPoint(tv.horizontalHeader()->sectionViewportPosition(0) + tv.horizontalHeader()->sectionSize(0) / 2, 5)); - QCOMPARE(clickedSpy.count(), 3); - QCOMPARE(pressedSpy.count(), 3); + QCOMPARE(clickedSpy.size(), 3); + QCOMPARE(pressedSpy.size(), 3); QCOMPARE(clickedSpy.at(2).at(0).toInt(), 0); QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0); } @@ -2541,7 +2541,7 @@ public: void insertRowAtBeginning() { Q_EMIT layoutAboutToBeChanged(); - m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count())); + m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.size())); // Rows are always inserted at the beginning, so move all others. const auto pl = persistentIndexList(); // The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning. @@ -2557,7 +2557,7 @@ public: QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); } QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } - int rowCount(const QModelIndex &) const override { return m_displayNames.count(); } + int rowCount(const QModelIndex &) const override { return m_displayNames.size(); } int columnCount(const QModelIndex &) const override { return 1; } private: diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 8e78b215da..aa17026daf 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -327,7 +327,7 @@ void tst_QItemDelegate::editorKeyPress() view.edit(index); QList<QLineEdit*> lineEditors = view.viewport()->findChildren<QLineEdit *>(); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QLineEdit *editor = lineEditors.at(0); QCOMPARE(editor->selectedText(), initial); @@ -355,7 +355,7 @@ void tst_QItemDelegate::doubleEditorNegativeInput() view.edit(index); QList<QDoubleSpinBox*> editors = view.viewport()->findChildren<QDoubleSpinBox *>(); - QCOMPARE(editors.count(), 1); + QCOMPARE(editors.size(), 1); QDoubleSpinBox *editor = editors.at(0); QCOMPARE(editor->value(), double(10)); @@ -672,33 +672,33 @@ void tst_QItemDelegate::testEventFilter() //For each test we send a key event and check if signals were emitted. event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); QVERIFY(delegate.eventFilter(&widget, event)); - QCOMPARE(closeEditorSpy.count(), 1); - QCOMPARE(commitDataSpy.count(), 1); + QCOMPARE(closeEditorSpy.size(), 1); + QCOMPARE(commitDataSpy.size(), 1); delete event; event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier); QVERIFY(delegate.eventFilter(&widget, event)); - QCOMPARE(closeEditorSpy.count(), 2); - QCOMPARE(commitDataSpy.count(), 2); + QCOMPARE(closeEditorSpy.size(), 2); + QCOMPARE(commitDataSpy.size(), 2); delete event; event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier); QVERIFY(delegate.eventFilter(&widget, event)); - QCOMPARE(closeEditorSpy.count(), 3); - QCOMPARE(commitDataSpy.count(), 2); + QCOMPARE(closeEditorSpy.size(), 3); + QCOMPARE(commitDataSpy.size(), 2); delete event; event = new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier); QVERIFY(!delegate.eventFilter(&widget, event)); - QCOMPARE(closeEditorSpy.count(), 3); - QCOMPARE(commitDataSpy.count(), 2); + QCOMPARE(closeEditorSpy.size(), 3); + QCOMPARE(commitDataSpy.size(), 2); delete event; //Subtest focusEvent event = new QFocusEvent(QEvent::FocusOut); QVERIFY(!delegate.eventFilter(&widget, event)); - QCOMPARE(closeEditorSpy.count(), 4); - QCOMPARE(commitDataSpy.count(), 3); + QCOMPARE(closeEditorSpy.size(), 4); + QCOMPARE(commitDataSpy.size(), 3); delete event; } @@ -1314,7 +1314,7 @@ void tst_QItemDelegate::enterKey() view.edit(index); QList<QWidget*> lineEditors = view.viewport()->findChildren<QWidget *>(QString::fromLatin1("TheEditor")); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QPointer<QWidget> editor = lineEditors.at(0); QCOMPARE(editor->hasFocus(), true); @@ -1348,7 +1348,7 @@ void tst_QItemDelegate::task257859_finalizeEdit() view.edit(index); QList<QLineEdit *> lineEditors = view.viewport()->findChildren<QLineEdit *>(); - QCOMPARE(lineEditors.count(), 1); + QCOMPARE(lineEditors.size(), 1); QPointer<QWidget> editor = lineEditors.at(0); QCOMPARE(editor->hasFocus(), true); @@ -1479,7 +1479,7 @@ void tst_QItemDelegate::testLineEditValidation() const auto findEditors = [&]() { return view.findChildren<QLineEdit *>(QStringLiteral("TheEditor")); }; - QCOMPARE(findEditors().count(), 1); + QCOMPARE(findEditors().size(), 1); editor = findEditors().at(0); editor->clear(); @@ -1499,7 +1499,7 @@ void tst_QItemDelegate::testLineEditValidation() view.setCurrentIndex(index); view.edit(index); - QTRY_COMPARE(findEditors().count(), 1); + QTRY_COMPARE(findEditors().size(), 1); editor = findEditors().at(0); editor->clear(); @@ -1521,13 +1521,13 @@ void tst_QItemDelegate::testLineEditValidation() // reset the view to forcibly close the editor view.reset(); - QTRY_COMPARE(findEditors().count(), 0); + QTRY_COMPARE(findEditors().size(), 0); // set a valid text again view.setCurrentIndex(index); view.edit(index); - QTRY_COMPARE(findEditors().count(), 1); + QTRY_COMPARE(findEditors().size(), 1); editor = findEditors().at(0); editor->clear(); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index ad52e40254..c85ed7e35b 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -718,7 +718,7 @@ void tst_QListView::clicked() continue; QSignalSpy spy(&view, &QListView::clicked); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } } @@ -1147,7 +1147,7 @@ void tst_QListView::selection() v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect); const QModelIndexList selected = v.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), expectedItems.count()); + QCOMPARE(selected.size(), expectedItems.size()); for (const auto &idx : selected) QVERIFY(expectedItems.contains(idx.row())); } @@ -1557,7 +1557,7 @@ void tst_QListView::task203585_selectAll() QVERIFY(view.selectionModel()->selectedIndexes().isEmpty()); view.setRowHidden(0, false); view.selectAll(); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); } void tst_QListView::task228566_infiniteRelayout() @@ -1642,7 +1642,7 @@ void tst_QListView::task196118_visualRegionForSelection() view.selectionModel()->select(top1.index(), QItemSelectionModel::Select); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); QVERIFY(view.getVisualRegionForSelection().isEmpty()); } @@ -1740,7 +1740,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() QTRY_COMPARE(view.currentIndex(), model.index(1, 0)); QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 3); + QCOMPARE(selected.size(), 3); QVERIFY(!selected.contains(model.index(0, 0))); } { // Second test: QListView::TopToBottom flow @@ -1767,7 +1767,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() QTRY_COMPARE(view.currentIndex(), model.index(1, 0)); QModelIndexList selected = view.selectionModel()->selectedIndexes(); - QCOMPARE(selected.count(), 3); + QCOMPARE(selected.size(), 3); QVERIFY(!selected.contains(model.index(0, 0))); } } @@ -1829,7 +1829,7 @@ void tst_QListView::clickOnViewportClearsSelection() view.selectAll(); QModelIndex index = model.index(0); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); QVERIFY(view.selectionModel()->isSelected(index)); //we try to click outside of the index @@ -1837,7 +1837,7 @@ void tst_QListView::clickOnViewportClearsSelection() QTest::mousePress(view.viewport(), Qt::LeftButton, {}, point); //at this point, the selection shouldn't have changed - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1); QVERIFY(view.selectionModel()->isSelected(index)); QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, point); @@ -1946,7 +1946,7 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick() view.setModel(&model); view.setSelectionMode(QAbstractItemView::ExtendedSelection); view.selectAll(); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), model.rowCount()); const QRect itemRect = view.visualRect(model.index(model.rowCount() - 1)); @@ -1956,7 +1956,7 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick() QVERIFY(!view.selectionModel()->hasSelection()); view.selectAll(); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), model.rowCount()); //and now the right button QTest::mouseClick(view.viewport(), Qt::RightButton, {}, p); @@ -2715,9 +2715,9 @@ public: if (idxPar.isValid()) { TstMoveItem *parentItem = static_cast<TstMoveItem *>(idxPar.internalPointer()); Q_ASSERT(parentItem); - cnt = parentItem->childItems.count(); + cnt = parentItem->childItems.size(); } else { - cnt = rootItem->childItems.count(); + cnt = rootItem->childItems.size(); } return cnt; } @@ -2734,9 +2734,9 @@ public: if (parent.isValid()) { TstMoveItem *parentItem = static_cast<TstMoveItem *>(parent.internalPointer()); Q_ASSERT(parentItem); - ret = parentItem->childItems.count() > 0; + ret = parentItem->childItems.size() > 0; } else { - ret = rootItem->childItems.count() > 0; + ret = rootItem->childItems.size() > 0; } return ret; } @@ -2758,8 +2758,8 @@ public: TstMoveItem *itmDestParent = itemAt(destinationParent); if (itmSrcParent && sourceRow >= 0 - && sourceRow + count <= itmSrcParent->childItems.count() - && itmDestParent && destinationChild <= itmDestParent->childItems.count()) { + && sourceRow + count <= itmSrcParent->childItems.size() + && itmDestParent && destinationChild <= itmDestParent->childItems.size()) { beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, destinationParent, destinationChild); QList<TstMoveItem *> itemsToMove; @@ -2767,7 +2767,7 @@ public: TstMoveItem *itm = itmSrcParent->childItems.at(sourceRow+i); itemsToMove.append(itm); } - for (int i = itemsToMove.count() -1; i >= 0; --i) { + for (int i = itemsToMove.size() -1; i >= 0; --i) { TstMoveItem *itm = itemsToMove.at(i); itm->parentItem->childItems.removeAll(itm); itm->parentItem = itmDestParent; @@ -3169,7 +3169,7 @@ void tst_QListView::scrollOnRemove() model.removeRow(25); // if nothing is selected now, then the view should not have scrolled - if (!view.selectionModel()->selectedIndexes().count()) + if (!view.selectionModel()->selectedIndexes().size()) QTRY_COMPARE(view.verticalScrollBar()->value(), item25Position); } diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 3fe14c682c..9ff0ac91e1 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -344,7 +344,7 @@ void tst_QListWidget::addItems() QString::number(testWidget->count() + 3), label}; testWidget->addItems(stringList); - QCOMPARE(testWidget->count(), count + stringList.count()); + QCOMPARE(testWidget->count(), count + stringList.size()); QCOMPARE(testWidget->item(testWidget->count()-1)->text(), label); } @@ -356,30 +356,30 @@ void tst_QListWidget::openPersistentEditor() QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count())); testWidget->openPersistentEditor(item); - int childCount = testWidget->viewport()->children().count(); + int childCount = testWidget->viewport()->children().size(); testWidget->addItem(item); testWidget->openPersistentEditor(item); - QCOMPARE(childCount + 1, testWidget->viewport()->children().count()); + QCOMPARE(childCount + 1, testWidget->viewport()->children().size()); } void tst_QListWidget::closePersistentEditor() { // Boundary checking - int childCount = testWidget->viewport()->children().count(); + int childCount = testWidget->viewport()->children().size(); testWidget->closePersistentEditor(nullptr); QListWidgetItem *item = new QListWidgetItem(QString::number(testWidget->count())); testWidget->closePersistentEditor(item); - QCOMPARE(childCount, testWidget->viewport()->children().count()); + QCOMPARE(childCount, testWidget->viewport()->children().size()); // Create something testWidget->addItem(item); testWidget->openPersistentEditor(item); // actual test - childCount = testWidget->viewport()->children().count(); + childCount = testWidget->viewport()->children().size(); testWidget->closePersistentEditor(item); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); - QCOMPARE(testWidget->viewport()->children().count(), childCount - 1); + QCOMPARE(testWidget->viewport()->children().size(), childCount - 1); } void tst_QListWidget::setItemHidden() @@ -529,7 +529,7 @@ void tst_QListWidget::editItem() item->setFlags(item->flags() | Qt::ItemIsEditable); testWidget->addItem(item); - int childCount = testWidget->viewport()->children().count(); + int childCount = testWidget->viewport()->children().size(); QWidget *existsAlready = testWidget->indexWidget(testWidget->model()->index(testWidget->row(item), 0)); testWidget->editItem(item); Qt::ItemFlags flags = item->flags(); @@ -537,7 +537,7 @@ void tst_QListWidget::editItem() // There doesn't seem to be a way to detect if the item has already been edited... if (!existsAlready && flags & Qt::ItemIsEditable && flags & Qt::ItemIsEnabled) { QList<QObject *> children = testWidget->viewport()->children(); - QVERIFY(children.count() > childCount); + QVERIFY(children.size() > childCount); bool found = false; for (int i = 0; i < children.size(); ++i) { if (children.at(i)->inherits("QExpandingLineEdit")) @@ -545,7 +545,7 @@ void tst_QListWidget::editItem() } QVERIFY(found); } else { - QCOMPARE(testWidget->viewport()->children().count(), childCount); + QCOMPARE(testWidget->viewport()->children().size(), childCount); } } @@ -554,12 +554,12 @@ void tst_QListWidget::findItems() // This really just tests that the items that are returned are converted from index's to items correctly. // Boundary checking - QCOMPARE(testWidget->findItems("GirlsCanWearJeansAndCutTheirHairShort", Qt::MatchExactly).count(), 0); + QCOMPARE(testWidget->findItems("GirlsCanWearJeansAndCutTheirHairShort", Qt::MatchExactly).size(), 0); populate(); for (int i = 0; i < testWidget->count(); ++i) - QCOMPARE(testWidget->findItems(testWidget->item(i)->text(), Qt::MatchExactly).count(), 1); + QCOMPARE(testWidget->findItems(testWidget->item(i)->text(), Qt::MatchExactly).size(), 1); } @@ -574,8 +574,8 @@ void tst_QListWidget::insertItem_data() QTest::newRow("Insert less then 0") << initialItems << -1 << "inserted" << 0; QTest::newRow("Insert at 0") << initialItems << 0 << "inserted" << 0; - QTest::newRow("Insert beyond count") << initialItems << initialItems.count()+1 << "inserted" << initialItems.count(); - QTest::newRow("Insert at count") << initialItems << initialItems.count() << "inserted" << initialItems.count(); + QTest::newRow("Insert beyond count") << initialItems << initialItems.size()+1 << "inserted" << initialItems.size(); + QTest::newRow("Insert at count") << initialItems << initialItems.size() << "inserted" << initialItems.size(); QTest::newRow("Insert in the middle") << initialItems << 1 << "inserted" << 1; } @@ -587,7 +587,7 @@ void tst_QListWidget::insertItem() QFETCH(int, expectedIndex); testWidget->insertItems(0, initialItems); - QCOMPARE(testWidget->count(), initialItems.count()); + QCOMPARE(testWidget->count(), initialItems.size()); testWidget->insertItem(insertIndex, itemLabel); @@ -596,7 +596,7 @@ void tst_QListWidget::insertItem() QCOMPARE(rcFirst[RowsInserted], expectedIndex); QCOMPARE(rcLast[RowsInserted], expectedIndex); - QCOMPARE(testWidget->count(), initialItems.count() + 1); + QCOMPARE(testWidget->count(), initialItems.size() + 1); QCOMPARE(testWidget->item(expectedIndex)->text(), itemLabel); } @@ -669,8 +669,8 @@ void tst_QListWidget::insertItems() for (int i = 0; i < testWidget->count(); ++i) QCOMPARE(testWidget->item(i)->listWidget(), testWidget); - QCOMPARE(itemChangedSpy.count(), 0); - QCOMPARE(dataChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); + QCOMPARE(dataChangedSpy.size(), 0); } void tst_QListWidget::itemAssignment() @@ -825,7 +825,7 @@ void tst_QListWidget::selectedItems() QListWidgetItem *item = testWidget->item(i); item->setSelected(true); QVERIFY(item->isSelected()); - QCOMPARE(testWidget->selectedItems().count(), 1); + QCOMPARE(testWidget->selectedItems().size(), 1); } //let's clear the selection testWidget->clearSelection(); @@ -843,7 +843,7 @@ void tst_QListWidget::selectedItems() // check that the correct number of items and the expected items are there QList<QListWidgetItem *> selectedItems = testWidget->selectedItems(); - QCOMPARE(selectedItems.count(), expectedRows.count()); + QCOMPARE(selectedItems.size(), expectedRows.size()); for (int row : expectedRows) QVERIFY(selectedItems.contains(testWidget->item(row))); @@ -939,20 +939,20 @@ void tst_QListWidget::moveItemsPriv() else QCOMPARE(testWidget->item(dstRow)->text(), QString::number(srcRow)); - QCOMPARE(beginMoveSpy.count(), 1); + QCOMPARE(beginMoveSpy.size(), 1); const QList<QVariant> &beginMoveArgs = beginMoveSpy.takeFirst(); QCOMPARE(beginMoveArgs.at(1).toInt(), srcRow); QCOMPARE(beginMoveArgs.at(2).toInt(), srcRow); QCOMPARE(beginMoveArgs.at(4).toInt(), dstRow); - QCOMPARE(movedSpy.count(), 1); + QCOMPARE(movedSpy.size(), 1); const QList<QVariant> &movedArgs = movedSpy.takeFirst(); QCOMPARE(movedArgs.at(1).toInt(), srcRow); QCOMPARE(movedArgs.at(2).toInt(), srcRow); QCOMPARE(movedArgs.at(4).toInt(), dstRow); } else { - QCOMPARE(beginMoveSpy.count(), 0); - QCOMPARE(movedSpy.count(), 0); + QCOMPARE(beginMoveSpy.size(), 0); + QCOMPARE(movedSpy.size(), 0); } } @@ -1045,7 +1045,7 @@ void tst_QListWidget::sortItems() testWidget->sortItems(order); - QCOMPARE(testWidget->count(), expectedList.count()); + QCOMPARE(testWidget->count(), expectedList.size()); for (int i = 0; i < testWidget->count(); ++i) QCOMPARE(testWidget->item(i)->text(), expectedList.at(i).toString()); @@ -1115,7 +1115,7 @@ void tst_QListWidget::sortHiddenItems() tw->setSortingEnabled(true); tw->sortItems(order); - QCOMPARE(tw->count(), expectedList.count()); + QCOMPARE(tw->count(), expectedList.size()); for (int i = 0; i < tw->count(); ++i) { QCOMPARE(tw->item(i)->text(), expectedList.at(i)); QCOMPARE(tw->item(i)->isHidden(), !expectedVisibility.at(i)); @@ -1212,17 +1212,17 @@ void tst_QListWidget::setData() QFETCH(QVariantList, values); QFETCH(int, expectedSignalCount); - QCOMPARE(roles.count(), values.count()); + QCOMPARE(roles.size(), values.size()); for (int manipulateModel = 0; manipulateModel < 2; ++manipulateModel) { testWidget->clear(); testWidget->insertItems(0, initialItems); - QCOMPARE(testWidget->count(), initialItems.count()); + QCOMPARE(testWidget->count(), initialItems.size()); QSignalSpy itemChanged(testWidget, &QListWidget::itemChanged); QSignalSpy dataChanged(testWidget->model(), &QAbstractItemModel::dataChanged); - for (int i = 0; i < roles.count(); ++i) { + for (int i = 0; i < roles.size(); ++i) { if (manipulateModel) testWidget->model()->setData( testWidget->model()->index(itemIndex, 0, testWidget->rootIndex()), @@ -1233,12 +1233,12 @@ void tst_QListWidget::setData() } // make sure the data is actually set - for (int i = 0; i < roles.count(); ++i) + for (int i = 0; i < roles.size(); ++i) QCOMPARE(testWidget->item(itemIndex)->data(roles.at(i)), values.at(i)); // make sure we get the right number of emits - QCOMPARE(itemChanged.count(), expectedSignalCount); - QCOMPARE(dataChanged.count(), expectedSignalCount); + QCOMPARE(itemChanged.size(), expectedSignalCount); + QCOMPARE(dataChanged.size(), expectedSignalCount); } } @@ -1380,11 +1380,11 @@ void tst_QListWidget::insertItemsWithSorting() w.addItem(str); break; } - QCOMPARE(w.count(), expectedItems.count()); + QCOMPARE(w.count(), expectedItems.size()); for (int i = 0; i < w.count(); ++i) QCOMPARE(w.item(i)->text(), expectedItems.at(i)); - for (int k = 0; k < persistent.count(); ++k) + for (int k = 0; k < persistent.size(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); } } @@ -1480,7 +1480,7 @@ void tst_QListWidget::itemData() QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i }); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); - QCOMPARE(flags.count(), 6); + QCOMPARE(flags.size(), 6); for (int i = 0; i < 4; ++i) QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1)); @@ -1524,19 +1524,19 @@ void tst_QListWidget::changeDataWithSorting() QListWidgetItem *item = w.item(itemIndex); item->setText(newValue); - for (int i = 0; i < expectedItems.count(); ++i) { + for (int i = 0; i < expectedItems.size(); ++i) { QCOMPARE(w.item(i)->text(), expectedItems.at(i)); - for (int j = 0; j < persistent.count(); ++j) { + for (int j = 0; j < persistent.size(); ++j) { if (persistent.at(j).row() == i) // the same toplevel row QCOMPARE(persistent.at(j).internalPointer(), static_cast<void *>(w.item(i))); } } - for (int k = 0; k < persistent.count(); ++k) + for (int k = 0; k < persistent.size(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); - QCOMPARE(dataChangedSpy.count(), 1); - QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0); + QCOMPARE(dataChangedSpy.size(), 1); + QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0); } void tst_QListWidget::itemWidget() @@ -1615,7 +1615,7 @@ void tst_QListWidget::insertUnchanged() QListWidget w; QSignalSpy itemChangedSpy(&w, &QListWidget::itemChanged); QListWidgetItem item("foo", &w); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); } void tst_QListWidget::setSortingEnabled() @@ -1706,12 +1706,12 @@ void tst_QListWidget::QTBUG8086_currentItemChangedOnClick() QVERIFY(QTest::qWaitForWindowExposed(&win)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QTest::mouseClick(list.viewport(), Qt::LeftButton, {}, list.visualItemRect(list.item(2)).center()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } @@ -1810,14 +1810,14 @@ void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet() QSignalSpy currentItemChangedSpy(&list, &QListWidget::currentItemChanged); QSignalSpy itemSelectionChangedSpy(&list, &QListWidget::itemSelectionChanged); - QCOMPARE(currentItemChangedSpy.count(), 0); - QCOMPARE(itemSelectionChangedSpy.count(), 0); + QCOMPARE(currentItemChangedSpy.size(), 0); + QCOMPARE(itemSelectionChangedSpy.size(), 0); QTest::mouseClick(list.viewport(), Qt::LeftButton, {}, list.visualItemRect(list.item(2)).center()); - QCOMPARE(currentItemChangedSpy.count(), 1); - QCOMPARE(itemSelectionChangedSpy.count(), 1); + QCOMPARE(currentItemChangedSpy.size(), 1); + QCOMPARE(itemSelectionChangedSpy.size(), 1); } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index edd5453259..50d22addac 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -503,7 +503,7 @@ void tst_QTableView::emptyModel() QSignalSpy spy(&model, &QtTestTableModel::invalidIndexEncountered); view.setModel(&model); view.show(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTableView::removeRows_data() @@ -528,10 +528,10 @@ void tst_QTableView::removeRows() view.show(); model.removeLastRow(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); model.removeAllRows(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTableView::removeColumns_data() @@ -556,10 +556,10 @@ void tst_QTableView::removeColumns() view.show(); model.removeLastColumn(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); model.removeAllColumns(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTableView::keyboardNavigation_data() @@ -1597,7 +1597,7 @@ void tst_QTableView::selection() view.setSelection(QRect(x, y, width, height), command); - QCOMPARE(view.selectedIndexes().count(), selectedCount); + QCOMPARE(view.selectedIndexes().size(), selectedCount); } void tst_QTableView::selectRow_data() @@ -1710,12 +1710,12 @@ void tst_QTableView::selectRow() view.setSelectionMode(mode); view.setSelectionBehavior(behavior); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0); view.selectRow(row); //test we have 10 items selected - QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedItems); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedItems); //test that all 10 items are in the same row for (int i = 0; selectedItems > 0 && i < rowCount; ++i) QCOMPARE(view.selectionModel()->selectedIndexes().at(i).row(), row); @@ -1831,11 +1831,11 @@ void tst_QTableView::selectColumn() view.setSelectionMode(mode); view.setSelectionBehavior(behavior); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), 0); view.selectColumn(column); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedItems); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedItems); for (int i = 0; selectedItems > 0 && i < columnCount; ++i) QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column); } @@ -1980,22 +1980,22 @@ void tst_QTableView::selectall() // try slot first view.clearSelection(); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); view.selectAll(); - QCOMPARE(view.selectedIndexes().count(), selectedCount); + QCOMPARE(view.selectedIndexes().size(), selectedCount); // try by key sequence view.clearSelection(); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll)); - QCOMPARE(view.selectedIndexes().count(), selectedCount); + QCOMPARE(view.selectedIndexes().size(), selectedCount); // check again with no selection mode view.clearSelection(); view.setSelectionMode(QAbstractItemView::NoSelection); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll)); - QCOMPARE(view.selectedIndexes().count(), 0); + QCOMPARE(view.selectedIndexes().size(), 0); } #endif // QT_CONFIG(shortcut) @@ -2188,7 +2188,7 @@ void tst_QTableView::resizeRowsToContents() QSignalSpy resizedSpy(view.verticalHeader(), &QHeaderView::sectionResized); view.resizeRowsToContents(); - QCOMPARE(resizedSpy.count(), model.rowCount()); + QCOMPARE(resizedSpy.size(), model.rowCount()); for (int r = 0; r < model.rowCount(); ++r) QCOMPARE(view.rowHeight(r), rowHeight); } @@ -2234,7 +2234,7 @@ void tst_QTableView::resizeColumnsToContents() QSignalSpy resizedSpy(view.horizontalHeader(), &QHeaderView::sectionResized); view.resizeColumnsToContents(); - QCOMPARE(resizedSpy.count(), model.columnCount()); + QCOMPARE(resizedSpy.size(), model.columnCount()); for (int c = 0; c < model.columnCount(); ++c) QCOMPARE(view.columnWidth(c), columnWidth); } @@ -2348,7 +2348,7 @@ void tst_QTableView::rowAt() for (int r = 0; r < rowCount; ++r) view.setRowHeight(r, rowHeight); - for (int i = 0; i < hiddenRows.count(); ++i) + for (int i = 0; i < hiddenRows.size(); ++i) view.hideRow(hiddenRows.at(i)); QCOMPARE(view.rowAt(coordinate), row); @@ -2511,7 +2511,7 @@ void tst_QTableView::columnAt() for (int c = 0; c < columnCount; ++c) view.setColumnWidth(c, columnWidth); - for (int i = 0; i < hiddenColumns.count(); ++i) + for (int i = 0; i < hiddenColumns.size(); ++i) view.hideColumn(hiddenColumns.at(i)); QCOMPARE(view.columnAt(coordinate), column); diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index 39cbe0ab66..02d93bd356 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -192,8 +192,8 @@ void tst_QTableWidget::clear() QVERIFY(bla.isNull()); QVERIFY(!testWidget->item(0,0)); - QVERIFY(!testWidget->selectedRanges().count()); - QVERIFY(!testWidget->selectedItems().count()); + QVERIFY(!testWidget->selectedRanges().size()); + QVERIFY(!testWidget->selectedItems().size()); } void tst_QTableWidget::rowCount() @@ -360,7 +360,7 @@ void tst_QTableWidget::takeItem() QCOMPARE(item->text(), QString::number(row * column + column)); delete item; - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); const QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 2); QCOMPARE(arguments.at(0).toInt(), row); @@ -525,24 +525,24 @@ void tst_QTableWidget::selectedItems() testWidget->setColumnHidden(column, true); // make sure we don't have any previous selections hanging around - QVERIFY(!testWidget->selectedRanges().count()); - QVERIFY(!testWidget->selectedItems().count()); + QVERIFY(!testWidget->selectedRanges().size()); + QVERIFY(!testWidget->selectedItems().size()); // select range and check that it is set correctly testWidget->setRangeSelected(selectionRange, true); if (selectionRange.topRow() >= 0) { - QCOMPARE(testWidget->selectedRanges().count(), 1); + QCOMPARE(testWidget->selectedRanges().size(), 1); QCOMPARE(testWidget->selectedRanges().at(0).topRow(), selectionRange.topRow()); QCOMPARE(testWidget->selectedRanges().at(0).bottomRow(), selectionRange.bottomRow()); QCOMPARE(testWidget->selectedRanges().at(0).leftColumn(), selectionRange.leftColumn()); QCOMPARE(testWidget->selectedRanges().at(0).rightColumn(), selectionRange.rightColumn()); } else { - QCOMPARE(testWidget->selectedRanges().count(), 0); + QCOMPARE(testWidget->selectedRanges().size(), 0); } // check that the correct number of items and the expected items are there const QList<QTableWidgetItem *> selectedItems = testWidget->selectedItems(); - QCOMPARE(selectedItems.count(), expectedItems.count()); + QCOMPARE(selectedItems.size(), expectedItems.size()); for (const auto &intPair : expectedItems) QVERIFY(selectedItems.contains(testWidget->item(intPair.first, intPair.second))); @@ -627,7 +627,7 @@ void tst_QTableWidget::selectedSpannedCells() // QTBUG-255 testWidget.visualRect(testWidget.model()->index(selectionEndCell.y(), selectionEndCell.x())).center()); auto ranges = testWidget.selectedRanges(); - QCOMPARE(ranges.count(), expectedSelectionRangeCount); + QCOMPARE(ranges.size(), expectedSelectionRangeCount); QCOMPARE(ranges.first(), expectedFirstSelectionRange); } @@ -1194,15 +1194,15 @@ void tst_QTableWidget::sortItems() persistent << model->index(r, sortColumn, QModelIndex()); } - for (int h = 0; h < initialHidden.count(); ++h) + for (int h = 0; h < initialHidden.size(); ++h) testWidget->hideRow(initialHidden.at(h)); - QCOMPARE(testWidget->verticalHeader()->hiddenSectionCount(), initialHidden.count()); + QCOMPARE(testWidget->verticalHeader()->hiddenSectionCount(), initialHidden.size()); testWidget->sortItems(sortColumn, sortOrder); int te = 0; - for (int i = 0; i < rows.count(); ++i) { + for (int i = 0; i < rows.size(); ++i) { for (int j = 0; j < columnCount; ++j) { QString value; QTableWidgetItem *itm = testWidget->item(i, j); @@ -1216,7 +1216,7 @@ void tst_QTableWidget::sortItems() // << "expected" << rows.at(i); } - for (int k = 0; k < expectedHidden.count(); ++k) + for (int k = 0; k < expectedHidden.size(); ++k) QVERIFY(testWidget->isRowHidden(expectedHidden.at(k))); } @@ -1397,18 +1397,18 @@ void tst_QTableWidget::setItemWithSorting() } } - for (int k = 0; k < persistent.count(); ++k) { + for (int k = 0; k < persistent.size(); ++k) { QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); int i = (persistent.at(k).row() * columnCount) + sortColumn; QCOMPARE(persistent.at(k).data().toString(), expectedValues.at(i)); } if (i == 0) - QCOMPARE(dataChangedSpy.count(), reorderingExpected ? 0 : 1); + QCOMPARE(dataChangedSpy.size(), reorderingExpected ? 0 : 1); else - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); - QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0); + QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0); } } @@ -1444,7 +1444,7 @@ void tst_QTableWidget::itemData() QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i }); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); - QCOMPARE(flags.count(), 6); + QCOMPARE(flags.size(), 6); for (int i = 0; i < 4; ++i) QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1)); } @@ -1457,7 +1457,7 @@ void tst_QTableWidget::setItemData() QTableWidgetItem *item = new QTableWidgetItem; table.setItem(0, 0, item); - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QModelIndex idx = qvariant_cast<QModelIndex>(dataChangedSpy.takeFirst().at(0)); QMap<int, QVariant> data; @@ -1469,7 +1469,7 @@ void tst_QTableWidget::setItemData() QCOMPARE(table.model()->data(idx, Qt::DisplayRole).toString(), QLatin1String("Display")); QCOMPARE(table.model()->data(idx, Qt::EditRole).toString(), QLatin1String("Display")); QCOMPARE(table.model()->data(idx, Qt::ToolTipRole).toString(), QLatin1String("ToolTip")); - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(idx, qvariant_cast<QModelIndex>(dataChangedSpy.first().at(0))); QCOMPARE(idx, qvariant_cast<QModelIndex>(dataChangedSpy.first().at(1))); const auto roles = qvariant_cast<QList<int>>(dataChangedSpy.first().at(2)); @@ -1480,13 +1480,13 @@ void tst_QTableWidget::setItemData() dataChangedSpy.clear(); table.model()->setItemData(idx, data); - QCOMPARE(dataChangedSpy.count(), 0); + QCOMPARE(dataChangedSpy.size(), 0); data.clear(); data.insert(Qt::DisplayRole, QLatin1String("dizplaye")); table.model()->setItemData(idx, data); QCOMPARE(table.model()->data(idx, Qt::DisplayRole).toString(), QLatin1String("dizplaye")); - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); QCOMPARE(QList<int>({ Qt::DisplayRole, Qt::EditRole }), qvariant_cast<QList<int>>(dataChangedSpy.first().at(2))); @@ -1649,7 +1649,7 @@ void tst_QTableWidget::task262056_sortDuplicate() QSignalSpy layoutChangedSpy(testWidget->model(), &QAbstractItemModel::layoutChanged); testWidget->item(3,0)->setBackground(Qt::red); - QCOMPARE(layoutChangedSpy.count(),0); + QCOMPARE(layoutChangedSpy.size(),0); } @@ -1746,7 +1746,7 @@ void tst_QTableWidget::selectedRowAfterSorting() table.setProperty("sortingEnabled",true); table.selectRow(1); table.item(1,1)->setText("9"); - QCOMPARE(table.selectedItems().count(),3); + QCOMPARE(table.selectedItems().size(),3); const auto selectedItems = table.selectedItems(); for (QTableWidgetItem *item : selectedItems) QCOMPARE(item->row(), 0); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 8fa942dd06..4e2903afd5 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -1279,7 +1279,7 @@ void tst_QTreeView::setModel() QCOMPARE(view.header()->model(), model); QCOMPARE(view.selectionModel() != oldSelectionModel, (i == 0)); } - QTRY_COMPARE(modelDestroyedSpy.count(), 0); + QTRY_COMPARE(modelDestroyedSpy.size(), 0); view.setModel(nullptr); QCOMPARE(view.model(), nullptr); @@ -1334,7 +1334,7 @@ void tst_QTreeView::setHeader() Qt::Orientation orient = x ? Qt::Vertical : Qt::Horizontal; QHeaderView *head = new QHeaderView(orient); view.setHeader(head); - QCOMPARE(destroyedSpy.count(), 1); + QCOMPARE(destroyedSpy.size(), 1); QCOMPARE(head->parent(), &view); QCOMPARE(view.header(), head); view.setHeader(head); @@ -1517,10 +1517,10 @@ void tst_QTreeView::limitedExpand() QVERIFY(spy.isValid()); view.expand(model.index(0, 0)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); view.expand(model.index(1, 0)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } { QStringListModel model(QStringList() << "one" << "two"); @@ -1531,9 +1531,9 @@ void tst_QTreeView::limitedExpand() QVERIFY(spy.isValid()); view.expand(model.index(0, 0)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); view.expandAll(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } } @@ -1572,58 +1572,58 @@ void tst_QTreeView::expandAndCollapse() view.expand(QModelIndex()); QCOMPARE(view.isExpanded(QModelIndex()), false); view.collapse(QModelIndex()); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 0); // expand a first level item QVERIFY(!view.isExpanded(a)); view.expand(a); QVERIFY(view.isExpanded(a)); - QCOMPARE(expandedSpy.count(), 1); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 1); + QCOMPARE(collapsedSpy.size(), 0); args = expandedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); view.expand(a); QVERIFY(view.isExpanded(a)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 0); // expand a second level item QVERIFY(!view.isExpanded(b)); view.expand(b); QVERIFY(view.isExpanded(a)); QVERIFY(view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 1); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 1); + QCOMPARE(collapsedSpy.size(), 0); args = expandedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), b); view.expand(b); QVERIFY(view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 0); // collapse the first level item view.collapse(a); QVERIFY(!view.isExpanded(a)); QVERIFY(view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 1); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 1); args = collapsedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); view.collapse(a); QVERIFY(!view.isExpanded(a)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 0); // expand the first level item again view.expand(a); QVERIFY(view.isExpanded(a)); QVERIFY(view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 1); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 1); + QCOMPARE(collapsedSpy.size(), 0); args = expandedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); @@ -1631,8 +1631,8 @@ void tst_QTreeView::expandAndCollapse() view.collapse(b); QVERIFY(view.isExpanded(a)); QVERIFY(!view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 1); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 1); args = collapsedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), b); @@ -1640,8 +1640,8 @@ void tst_QTreeView::expandAndCollapse() view.collapse(a); QVERIFY(!view.isExpanded(a)); QVERIFY(!view.isExpanded(b)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 1); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 1); args = collapsedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); @@ -1653,8 +1653,8 @@ void tst_QTreeView::expandAndCollapse() QVERIFY(view.isExpanded(a)); QVERIFY(view.isExpanded(b)); QVERIFY(!view.isExpanded(c)); - QCOMPARE(expandedSpy.count(), 2); - QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.size(), 2); + QCOMPARE(collapsedSpy.size(), 0); args = expandedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); args = expandedSpy.takeFirst(); @@ -1665,8 +1665,8 @@ void tst_QTreeView::expandAndCollapse() QVERIFY(!view.isExpanded(a)); QVERIFY(!view.isExpanded(b)); QVERIFY(!view.isExpanded(c)); - QCOMPARE(expandedSpy.count(), 0); - QCOMPARE(collapsedSpy.count(), 2); + QCOMPARE(expandedSpy.size(), 0); + QCOMPARE(collapsedSpy.size(), 2); args = collapsedSpy.takeFirst(); QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), a); args = collapsedSpy.takeFirst(); @@ -1728,22 +1728,22 @@ void tst_QTreeView::expandAndCollapseAll() view.expandAll(); checkExpandState(model, view, QModelIndex(), true, &count); - QCOMPARE(collapsedSpy.count(), 0); - QCOMPARE(expandedSpy.count(), 39); // == 3 (first) + 9 (second) + 27 (third level) + QCOMPARE(collapsedSpy.size(), 0); + QCOMPARE(expandedSpy.size(), 39); // == 3 (first) + 9 (second) + 27 (third level) QCOMPARE(count, 39); collapsedSpy.clear(); expandedSpy.clear(); view.collapseAll(); checkExpandState(model, view, QModelIndex(), false, &count); - QCOMPARE(collapsedSpy.count(), 39); - QCOMPARE(expandedSpy.count(), 0); + QCOMPARE(collapsedSpy.size(), 39); + QCOMPARE(expandedSpy.size(), 0); QCOMPARE(count, 39); collapsedSpy.clear(); expandedSpy.clear(); view.expandRecursively(model.index(0, 0)); - QCOMPARE(expandedSpy.count(), 13); // 1 + 3 + 9 + QCOMPARE(expandedSpy.size(), 13); // 1 + 3 + 9 checkExpandState(model, view, model.index(0, 0), true, &count); QCOMPARE(count, 13); @@ -1755,9 +1755,9 @@ void tst_QTreeView::expandAndCollapseAll() expandedSpy.clear(); view.collapseAll(); view.expandRecursively(model.index(0, 0), 1); - QCOMPARE(expandedSpy.count(), 4); // 1 + 3 + QCOMPARE(expandedSpy.size(), 4); // 1 + 3 view.expandRecursively(model.index(0, 0), 2); - QCOMPARE(expandedSpy.count(), 13); // (1 + 3) + 9 + QCOMPARE(expandedSpy.size(), 13); // (1 + 3) + 9 checkExpandState(model, view, model.index(0, 0), true, &count); QCOMPARE(count, 13); @@ -2043,7 +2043,7 @@ void tst_QTreeView::setSelection() QVERIFY(selectionModel); const QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - QCOMPARE(selectedIndexes.count(), expectedItems.count()); + QCOMPARE(selectedIndexes.size(), expectedItems.size()); for (const QModelIndex &idx : selectedIndexes) QVERIFY(expectedItems.contains(QPoint(idx.column(), idx.row()))); } @@ -2147,7 +2147,7 @@ void tst_QTreeView::clicked() continue; QSignalSpy spy(&view, &QTreeView::clicked); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); } } @@ -2228,7 +2228,7 @@ void tst_QTreeView::rowsAboutToBeRemoved() model.removeRows(1,1); QCOMPARE((view.state()), 0); // Should not be 5 (or any other number for that sake :) - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); } @@ -2540,28 +2540,28 @@ void tst_QTreeView::selectionWithHiddenItems() //child should not be selected as it is hidden (its parent is not expanded) view.selectAll(); - QCOMPARE(view.selectionModel()->selection().count(), 1); //one range - QCOMPARE(view.selectionModel()->selectedRows().count(), 4); + QCOMPARE(view.selectionModel()->selection().size(), 1); //one range + QCOMPARE(view.selectionModel()->selectedRows().size(), 4); view.expandAll(); QVERIFY(view.isExpanded(item1.index())); - QCOMPARE(view.selectionModel()->selection().count(), 1); - QCOMPARE(view.selectionModel()->selectedRows().count(), 4); + QCOMPARE(view.selectionModel()->selection().size(), 1); + QCOMPARE(view.selectionModel()->selectedRows().size(), 4); QVERIFY( !view.selectionModel()->isSelected(model.indexFromItem(&child))); view.clearSelection(); QVERIFY(view.isExpanded(item1.index())); //child should be selected as it is visible (its parent is expanded) view.selectAll(); - QCOMPARE(view.selectionModel()->selection().count(), 2); - QCOMPARE(view.selectionModel()->selectedRows().count(), 5); //everything is selected + QCOMPARE(view.selectionModel()->selection().size(), 2); + QCOMPARE(view.selectionModel()->selectedRows().size(), 5); //everything is selected view.clearSelection(); //we hide the node with a child (there should then be 3 items selected in 2 ranges) view.setRowHidden(1, QModelIndex(), true); QVERIFY(view.isExpanded(item1.index())); view.selectAll(); - QCOMPARE(view.selectionModel()->selection().count(), 2); - QCOMPARE(view.selectionModel()->selectedRows().count(), 3); + QCOMPARE(view.selectionModel()->selection().size(), 2); + QCOMPARE(view.selectionModel()->selectedRows().size(), 3); QVERIFY(!view.selectionModel()->isSelected(model.indexFromItem(&item1))); QVERIFY(!view.selectionModel()->isSelected(model.indexFromItem(&child))); @@ -2574,8 +2574,8 @@ void tst_QTreeView::selectionWithHiddenItems() QVERIFY(view.isExpanded(item1.index())); view.selectAll(); QVERIFY(view.isExpanded(item1.index())); - QCOMPARE(view.selectionModel()->selection().count(), 3); - QCOMPARE(view.selectionModel()->selectedRows().count(), 4); + QCOMPARE(view.selectionModel()->selection().size(), 3); + QCOMPARE(view.selectionModel()->selectedRows().size(), 4); QVERIFY( !view.selectionModel()->isSelected(model.indexFromItem(&item2))); view.setRowHidden(2, QModelIndex(), false); QVERIFY(view.isExpanded(item1.index())); @@ -2590,21 +2590,21 @@ void tst_QTreeView::selectAll() view2.setSelectionMode(QAbstractItemView::ExtendedSelection); view2.selectAll(); // Should work with an empty model //everything should be selected since we are in ExtendedSelection mode - QCOMPARE(view2.selectedIndexes().count(), model.rowCount() * model.columnCount()); + QCOMPARE(view2.selectedIndexes().size(), model.rowCount() * model.columnCount()); for (int i = 0; i < model.rowCount(); ++i) model.setData(model.index(i,0), QLatin1String("row ") + QString::number(i)); QTreeView view; view.setModel(&model); - int selectedCount = view.selectedIndexes().count(); + int selectedCount = view.selectedIndexes().size(); view.selectAll(); - QCOMPARE(view.selectedIndexes().count(), selectedCount); + QCOMPARE(view.selectedIndexes().size(), selectedCount); QTreeView view3; view3.setModel(&model); view3.setSelectionMode(QAbstractItemView::NoSelection); view3.selectAll(); - QCOMPARE(view3.selectedIndexes().count(), 0); + QCOMPARE(view3.selectedIndexes().size(), 0); } void tst_QTreeView::extendedSelection_data() @@ -2630,7 +2630,7 @@ void tst_QTreeView::extendedSelection() topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QTest::mousePress(view.viewport(), Qt::LeftButton, {}, mousePressPos); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), selectedCount); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), selectedCount); } void tst_QTreeView::rowSizeHint() @@ -2870,7 +2870,7 @@ public: } void kill() { - for (int i = children.count() -1; i >= 0; --i) { + for (int i = children.size() -1; i >= 0; --i) { children.at(i)->kill(); if (parent == nullptr) { deadChildren.append(children.at(i)); @@ -2912,7 +2912,7 @@ public: emit layoutAboutToBeChanged(); QModelIndexList oldList = persistentIndexList(); QList<QStack<int>> oldListPath; - for (int i = 0; i < oldList.count(); ++i) { + for (int i = 0; i < oldList.size(); ++i) { QModelIndex idx = oldList.at(i); QStack<int> path; while (idx.isValid()) { @@ -2943,7 +2943,7 @@ public: if (parentNode->isDead) qFatal("%s: parentNode is dead!", Q_FUNC_INFO); } - return parentNode->children.count(); + return parentNode->children.size(); } int columnCount(const QModelIndex &parent = QModelIndex()) const override { @@ -3534,7 +3534,7 @@ void tst_QTreeView::task174627_moveLeftToRoot() QSignalSpy spy(&view, &task174627_TreeView::signalCurrentChanged); QTest::keyClick(&view, Qt::Key_Left); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTreeView::task171902_expandWith1stColHidden() @@ -4040,7 +4040,7 @@ void tst_QTreeView::task248022_changeSelection() &view, &TreeView::handleSelectionChanged); QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, view.visualRect(model.index(1)).center()); - QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count()); + QCOMPARE(view.selectionModel()->selectedIndexes().size(), list.size()); } void tst_QTreeView::task245654_changeModelAndExpandAll() @@ -4089,7 +4089,7 @@ void tst_QTreeView::doubleClickedWithSpans() QTest::mousePress(view.viewport(), Qt::LeftButton, {}, p); QTest::mouseDClick(view.viewport(), Qt::LeftButton, {}, p); QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, p); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); //let's click on the 2nd column p.setX(p.x() + view.header()->sectionSize(0)); @@ -4100,7 +4100,7 @@ void tst_QTreeView::doubleClickedWithSpans() QTest::mousePress(view.viewport(), Qt::LeftButton, {}, p); QTest::mouseDClick(view.viewport(), Qt::LeftButton, {}, p); QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, p); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.size(), 2); } void tst_QTreeView::taskQTBUG_6450_selectAllWith1stColumnHidden() @@ -5117,7 +5117,7 @@ void tst_QTreeView::fetchUntilScreenFull() TreeItem* parentItem = parent.isValid() ? static_cast<TreeItem*>(parent.internalPointer()) : m_root; - return parentItem->children.count(); + return parentItem->children.size(); } int columnCount(const QModelIndex&) const override { return 2; } diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 652d6f76d9..4e48db662a 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -281,8 +281,8 @@ void tst_QTreeWidget::addTopLevelItem() while (!tops.isEmpty()) { TreeItem *ti = tops.takeFirst(); delete ti; - QCOMPARE(tree.topLevelItemCount(), tops.count()); - for (int i = 0; i < tops.count(); ++i) + QCOMPARE(tree.topLevelItemCount(), tops.size()); + for (int i = 0; i < tops.size(); ++i) QCOMPARE(tree.topLevelItem(i), tops.at(i)); } @@ -378,12 +378,12 @@ void tst_QTreeWidget::currentItem() tree.setCurrentItem(item); QCOMPARE(tree.currentItem(), item); - QCOMPARE(currentItemChangedSpy.count(), 1); + QCOMPARE(currentItemChangedSpy.size(), 1); QVariantList args = currentItemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(1)), previous); - QCOMPARE(itemSelectionChangedSpy.count(), 1); + QCOMPARE(itemSelectionChangedSpy.size(), 1); itemSelectionChangedSpy.clear(); previous = item; @@ -396,15 +396,15 @@ void tst_QTreeWidget::currentItem() if (!currentItemChangedSpy.isEmpty()) { // ### we get a currentItemChanged() when what really // changed was just currentColumn(). Should it be like this? - QCOMPARE(currentItemChangedSpy.count(), 1); + QCOMPARE(currentItemChangedSpy.size(), 1); QVariantList args = currentItemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(1)), item); if (tree.selectionBehavior() == QAbstractItemView::SelectItems) { - QCOMPARE(itemSelectionChangedSpy.count(), 1); + QCOMPARE(itemSelectionChangedSpy.size(), 1); itemSelectionChangedSpy.clear(); } else { - QCOMPARE(itemSelectionChangedSpy.count(), 0); + QCOMPARE(itemSelectionChangedSpy.size(), 0); } } } @@ -464,7 +464,7 @@ void tst_QTreeWidget::editItem() QTest::keyClick(editor, Qt::Key_A); QTest::keyClick(editor, Qt::Key_Enter); QCoreApplication::processEvents(); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); QVariantList args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem *>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), col); @@ -620,7 +620,7 @@ void tst_QTreeWidget::setItemHidden2() { // From Task 78587 const QStringList hl({"ID", "Desc"}); - testWidget->setColumnCount(hl.count()); + testWidget->setColumnCount(hl.size()); testWidget->setHeaderLabels(hl); testWidget->setSortingEnabled(true); @@ -821,7 +821,7 @@ void tst_QTreeWidget::selectedItems() // check selectedItems const auto sel = testWidget->selectedItems(); - QCOMPARE(sel.count(), expectedItems.count()); + QCOMPARE(sel.size(), expectedItems.size()); for (const auto &itemPath : expectedItems) { QTreeWidgetItem *item = nullptr; for (int index : itemPath) { @@ -857,7 +857,7 @@ void tst_QTreeWidget::selectedItems() } item->setSelected(false); } - QCOMPARE(testWidget->selectedItems().count(), 0); + QCOMPARE(testWidget->selectedItems().size(), 0); } void tst_QTreeWidget::itemAssignment() @@ -1090,9 +1090,9 @@ void tst_QTreeWidget::findItems() QList<QTreeWidgetItem*> result = testWidget->findItems(pattern, Qt::MatchExactly|Qt::MatchRecursive); - QCOMPARE(result.count(), resultCount); + QCOMPARE(result.size(), resultCount); - for (int k = 0; k < result.count() && k < resultText.count(); ++k) + for (int k = 0; k < result.size() && k < resultText.size(); ++k) QCOMPARE(result.at(k)->text(column), resultText.at(k)); } @@ -1110,7 +1110,7 @@ void tst_QTreeWidget::findItemsInColumn() // Recursively search column one for 400. QList<QTreeWidgetItem*> items = testWidget->findItems("400", Qt::MatchExactly|Qt::MatchRecursive, 1); - QCOMPARE(items.count(), 1); + QCOMPARE(items.size(), 1); } void tst_QTreeWidget::sortItems_data() @@ -1177,16 +1177,16 @@ void tst_QTreeWidget::sortItems() testWidget->sortItems(column, order); QCOMPARE(testWidget->sortColumn(), column); - for (int k = 0; k < topLevelResult.count(); ++k) { + for (int k = 0; k < topLevelResult.size(); ++k) { QTreeWidgetItem *item = testWidget->topLevelItem(k); QCOMPARE(item->text(column), topLevelResult.at(k)); - for (int l = 0; l < childResult.count(); ++l) + for (int l = 0; l < childResult.size(); ++l) QCOMPARE(item->child(l)->text(column), childResult.at(l)); } - for (int m = 0; m < tops.count(); ++m) + for (int m = 0; m < tops.size(); ++m) QCOMPARE(tops.at(m).row(), expectedTopRows.at(m)); - for (int n = 0; n < children.count(); ++n) + for (int n = 0; n < children.size(); ++n) QCOMPARE(children.at(n).row(), expectedChildRows.at(n)); } @@ -1346,17 +1346,17 @@ void tst_QTreeWidget::insertTopLevelItems_data() const QStringList insert{ "baz" }; QTest::newRow("Insert at count") << initial << insert - << initial.count() << initial.count() - << initial.count() << initial.count(); + << initial.size() << initial.size() + << initial.size() << initial.size(); QTest::newRow("Insert in the middle") << initial << insert - << (initial.count() / 2) << (initial.count() / 2) - << (initial.count() / 2) << (initial.count() / 2); + << (initial.size() / 2) << (initial.size() / 2) + << (initial.size() / 2) << (initial.size() / 2); QTest::newRow("Insert less than 0") << initial << insert << -1 << -1 << -1 << -1; QTest::newRow("Insert beyond count") << initial << insert - << initial.count() + 1 << -1 - << initial.count() + 1 << -1; + << initial.size() + 1 << -1 + << initial.size() + 1 << -1; } void tst_QTreeWidget::insertTopLevelItems() @@ -1371,26 +1371,26 @@ void tst_QTreeWidget::insertTopLevelItems() { // insert the initial items QCOMPARE(testWidget->topLevelItemCount(), 0); - for (int i = 0; i < initialText.count(); ++i) { + for (int i = 0; i < initialText.size(); ++i) { QTreeWidgetItem *top = new QTreeWidgetItem(QStringList(initialText.at(i))); testWidget->addTopLevelItem(top); QCOMPARE(testWidget->indexOfTopLevelItem(top), i); } - QCOMPARE(testWidget->topLevelItemCount(), initialText.count()); + QCOMPARE(testWidget->topLevelItemCount(), initialText.size()); } { // test adding children QTreeWidgetItem *topLevel = testWidget->topLevelItem(0); - for (int i = 0; i < initialText.count(); ++i) + for (int i = 0; i < initialText.size(); ++i) topLevel->addChild(new QTreeWidgetItem(QStringList(initialText.at(i)))); - QCOMPARE(topLevel->childCount(), initialText.count()); + QCOMPARE(topLevel->childCount(), initialText.size()); } { // test adding more top level items QTreeWidgetItem *topsy = new QTreeWidgetItem(QStringList(insertText.at(0))); testWidget->insertTopLevelItem(insertTopLevelIndex, topsy); if (expectedTopLevelIndex == -1) { - QCOMPARE(testWidget->topLevelItemCount(), initialText.count()); + QCOMPARE(testWidget->topLevelItemCount(), initialText.size()); delete topsy; } else { QTreeWidgetItem *item = testWidget->topLevelItem(expectedTopLevelIndex); @@ -1406,7 +1406,7 @@ void tst_QTreeWidget::insertTopLevelItems() QTreeWidgetItem *child = new QTreeWidgetItem(QStringList(insertText.at(0))); topLevel->insertChild(insertChildIndex, child); if (expectedChildIndex == -1) { - QCOMPARE(topLevel->childCount(), initialText.count()); + QCOMPARE(topLevel->childCount(), initialText.size()); delete child; } else { QTreeWidgetItem *item = topLevel->child(expectedChildIndex); @@ -1592,7 +1592,7 @@ void tst_QTreeWidget::scrollToItem() void tst_QTreeWidget::setSortingEnabled() { const QStringList hl{ "ID" }; - testWidget->setColumnCount(hl.count()); + testWidget->setColumnCount(hl.size()); testWidget->setHeaderLabels(hl); QTreeWidgetItem *item1 = new QTreeWidgetItem(testWidget); @@ -1661,7 +1661,7 @@ void tst_QTreeWidget::addChild() QList<QTreeWidgetItem*> taken = item->takeChildren(); QCOMPARE(taken, children); QCOMPARE(item->childCount(), 0); - for (int i = 0; i < taken.count(); ++i) { + for (int i = 0; i < taken.size(); ++i) { QCOMPARE(taken.at(i)->parent(), nullptr); QCOMPARE(taken.at(i)->treeWidget(), nullptr); item->addChild(taken.at(i)); // re-add @@ -1671,8 +1671,8 @@ void tst_QTreeWidget::addChild() while (!children.isEmpty()) { QTreeWidgetItem *ti = children.takeFirst(); delete ti; - QCOMPARE(item->childCount(), children.count()); - for (int i = 0; i < children.count(); ++i) + QCOMPARE(item->childCount(), children.size()); + for (int i = 0; i < children.size(); ++i) QCOMPARE(item->child(i), children.at(i)); } @@ -1719,9 +1719,9 @@ void tst_QTreeWidget::setData() QSignalSpy itemChangedSpy( testWidget, &QTreeWidget::itemChanged); headerItem->setText(0, "test"); - QCOMPARE(dataChangedSpy.count(), 0); - QCOMPARE(headerDataChangedSpy.count(), 1); - QCOMPARE(itemChangedSpy.count(), 0); // no itemChanged() signal for header item + QCOMPARE(dataChangedSpy.size(), 0); + QCOMPARE(headerDataChangedSpy.size(), 1); + QCOMPARE(itemChangedSpy.size(), 0); // no itemChanged() signal for header item headerItem->setData(-1, -1, QVariant()); } @@ -1739,24 +1739,24 @@ void tst_QTreeWidget::setData() const QString text = QLatin1String("text ") + iS; item->setText(j, text); QCOMPARE(item->text(j), text); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setText(j, text); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); QPixmap pixmap(32, 32); pixmap.fill((i == 1) ? Qt::red : Qt::green); QIcon icon(pixmap); item->setIcon(j, icon); QCOMPARE(item->icon(j), icon); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setIcon(j, icon); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); @@ -1764,94 +1764,94 @@ void tst_QTreeWidget::setData() const QString toolTip = QLatin1String("toolTip ") + iS; item->setToolTip(j, toolTip); QCOMPARE(item->toolTip(j), toolTip); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setToolTip(j, toolTip); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); const QString statusTip = QLatin1String("statusTip ") + iS; item->setStatusTip(j, statusTip); QCOMPARE(item->statusTip(j), statusTip); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setStatusTip(j, statusTip); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); const QString whatsThis = QLatin1String("whatsThis ") + iS; item->setWhatsThis(j, whatsThis); QCOMPARE(item->whatsThis(j), whatsThis); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setWhatsThis(j, whatsThis); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); QSize sizeHint(64*i, 48*i); item->setSizeHint(j, sizeHint); QCOMPARE(item->sizeHint(j), sizeHint); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setSizeHint(j, sizeHint); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); QFont font; item->setFont(j, font); QCOMPARE(item->font(j), font); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setFont(j, font); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); Qt::Alignment textAlignment((i == 1) ? Qt::AlignLeft|Qt::AlignVCenter : Qt::AlignRight); item->setTextAlignment(j, textAlignment); QCOMPARE(item->textAlignment(j), int(textAlignment)); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setTextAlignment(j, textAlignment); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); QColor backgroundColor((i == 1) ? Qt::blue : Qt::yellow); item->setBackground(j, backgroundColor); QCOMPARE(item->background(j).color(), backgroundColor); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setBackground(j, backgroundColor); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); const QColor foregroundColor((i == 1) ? Qt::green : Qt::cyan); item->setForeground(j, foregroundColor); QCOMPARE(item->foreground(j), foregroundColor); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setForeground(j, foregroundColor); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked); item->setCheckState(j, checkState); QCOMPARE(item->checkState(j), checkState); - QCOMPARE(itemChangedSpy.count(), 1); + QCOMPARE(itemChangedSpy.size(), 1); args = itemChangedSpy.takeFirst(); QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setCheckState(j, checkState); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); QCOMPARE(item->text(j), text); QCOMPARE(item->icon(j), icon); @@ -1884,7 +1884,7 @@ void tst_QTreeWidget::setData() QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item); QCOMPARE(qvariant_cast<int>(args.at(1)), j); item->setBackground(j, pixmap); - QCOMPARE(itemChangedSpy.count(), 0); + QCOMPARE(itemChangedSpy.size(), 0); item->setData(j, Qt::DisplayRole, QVariant()); item->setData(j, Qt::DecorationRole, QVariant()); @@ -1897,7 +1897,7 @@ void tst_QTreeWidget::setData() item->setData(j, Qt::BackgroundRole, QVariant()); item->setData(j, Qt::ForegroundRole, QVariant()); item->setData(j, Qt::CheckStateRole, QVariant()); - QCOMPARE(itemChangedSpy.count(), 11); + QCOMPARE(itemChangedSpy.size(), 11); itemChangedSpy.clear(); QCOMPARE(item->data(j, Qt::DisplayRole).toString(), QString()); @@ -1960,11 +1960,11 @@ void tst_QTreeWidget::itemData() QCOMPARE(widget.currentRoles, QList<int> { Qt::UserRole + i }); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); - QCOMPARE(flags.count(), 6); + QCOMPARE(flags.size(), 6); for (int i = 0; i < 4; ++i) QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1)); flags = widget.model()->itemData(widget.model()->index(0, 1)); - QCOMPARE(flags.count(), 0); + QCOMPARE(flags.size(), 0); item.setBackground(0, QBrush(Qt::red)); item.setForeground(0, QBrush(Qt::green)); @@ -2033,7 +2033,7 @@ void tst_QTreeWidget::setHeaderLabels() { QStringList list = QString("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z").split(QLatin1Char(',')); testWidget->setHeaderLabels(list); - QCOMPARE(testWidget->header()->count(), list.count()); + QCOMPARE(testWidget->header()->count(), list.size()); } void tst_QTreeWidget::setHeaderItem() @@ -2263,11 +2263,11 @@ void tst_QTreeWidget::insertItemsWithSorting() w.addTopLevelItem(new QTreeWidgetItem({ txt })); break; } - QCOMPARE(w.topLevelItemCount(), expectedItems.count()); + QCOMPARE(w.topLevelItemCount(), expectedItems.size()); for (int i = 0; i < w.topLevelItemCount(); ++i) QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i)); - for (int k = 0; k < persistent.count(); ++k) + for (int k = 0; k < persistent.size(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); } } @@ -2308,10 +2308,10 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting() QTreeWidgetItem *child = new QTreeWidgetItem(parent, {text}); items << child; } - QCOMPARE(parent->childCount(), childTexts.count()); + QCOMPARE(parent->childCount(), childTexts.size()); QVERIFY(parent->isExpanded()); } - QCOMPARE(tree.model()->rowCount(), parentTexts.count()); + QCOMPARE(tree.model()->rowCount(), parentTexts.size()); // verify that the items are still expanded for (const QTreeWidgetItem *item : qAsConst(items)) { @@ -2332,10 +2332,10 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting() PersistentModelIndexVec children; for (int i = 0; i < model->rowCount(parents.constFirst()); ++i) children.push_back(model->index(i, 0, parents.constFirst())); - for (int i = 0; i < parentResult.count(); ++i) { + for (int i = 0; i < parentResult.size(); ++i) { QTreeWidgetItem *item = tree.topLevelItem(i); QCOMPARE(item->text(0), parentResult.at(i)); - for (int j = 0; j < childResult.count(); ++j) + for (int j = 0; j < childResult.size(); ++j) QCOMPARE(item->child(j)->text(0), childResult.at(j)); } } @@ -2427,7 +2427,7 @@ void tst_QTreeWidget::changeDataWithSorting() QTreeWidgetItem *item = w.topLevelItem(itemIndex); item->setText(0, newValue); - for (int i = 0; i < expectedItems.count(); ++i) { + for (int i = 0; i < expectedItems.size(); ++i) { QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i)); for (const QPersistentModelIndex &p : qAsConst(persistent)) { if (p.row() == i) // the same toplevel row @@ -2435,11 +2435,11 @@ void tst_QTreeWidget::changeDataWithSorting() } } - for (int k = 0; k < persistent.count(); ++k) + for (int k = 0; k < persistent.size(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); - QCOMPARE(dataChangedSpy.count(), 1); - QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0); + QCOMPARE(dataChangedSpy.size(), 1); + QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0); } void tst_QTreeWidget::changeDataWithStableSorting_data() @@ -2596,7 +2596,7 @@ void tst_QTreeWidget::changeDataWithStableSorting() item->setText(0, newValue); if (forceChange) item->emitDataChanged(); - for (int i = 0; i < expectedItems.count(); ++i) { + for (int i = 0; i < expectedItems.size(); ++i) { QCOMPARE(w.topLevelItem(i)->text(0), expectedItems.at(i)); for (const QPersistentModelIndex &p : qAsConst(persistent)) { if (p.row() == i) // the same toplevel row @@ -2604,11 +2604,11 @@ void tst_QTreeWidget::changeDataWithStableSorting() } } - for (int k = 0; k < persistent.count(); ++k) + for (int k = 0; k < persistent.size(); ++k) QCOMPARE(persistent.at(k).row(), expectedRows.at(k)); - QCOMPARE(dataChangedSpy.count(), 1); - QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0); + QCOMPARE(dataChangedSpy.size(), 1); + QCOMPARE(layoutChangedSpy.size(), reorderingExpected ? 1 : 0); } void tst_QTreeWidget::sizeHint_data() @@ -2714,8 +2714,8 @@ void tst_QTreeWidget::sortedIndexOfChild() tw.sortItems(0, sortOrder); tw.expandAll(); - QCOMPARE(itms.count(), expectedIndexes.count()); - for (int j = 0; j < expectedIndexes.count(); ++j) + QCOMPARE(itms.size(), expectedIndexes.size()); + for (int j = 0; j < expectedIndexes.size(); ++j) QCOMPARE(top->indexOfChild(itms.at(j)), expectedIndexes.at(j)); } @@ -2740,8 +2740,8 @@ void tst_QTreeWidget::expandAndCallapse() tw.collapseItem(top); tw.collapseItem(top); - QCOMPARE(spy0.count(), 3); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy0.size(), 3); + QCOMPARE(spy1.size(), 2); } void tst_QTreeWidget::setDisabled() @@ -2854,13 +2854,13 @@ void tst_QTreeWidget::removeSelectedItem() QItemSelectionModel *selModel = w->selectionModel(); QCOMPARE(selModel->hasSelection(), true); - QCOMPARE(selModel->selectedRows().count(), 1); + QCOMPARE(selModel->selectedRows().size(), 1); const QScopedPointer<QTreeWidgetItem> taken(w->takeTopLevelItem(2)); QCOMPARE(taken->text(0), QLatin1String("C")); QCOMPARE(selModel->hasSelection(), false); - QCOMPARE(selModel->selectedRows().count(), 0); + QCOMPARE(selModel->selectedRows().size(), 0); QItemSelection sel = selModel->selection(); QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false); } @@ -2971,7 +2971,7 @@ protected: auto newItem = new QTreeWidgetItem({QString::number(i++)}); m_list.append(newItem); insertTopLevelItem(0, newItem); - while (m_list.count() > 10) + while (m_list.size() > 10) delete m_list.takeFirst(); } QTreeWidget::timerEvent(event); @@ -3285,7 +3285,7 @@ void tst_QTreeWidget::emitDataChanged() auto item = new PublicTreeItem; tree.insertTopLevelItem(0, item); item->emitDataChanged(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QTreeWidget::setCurrentItemExpandsParent() diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp index 7c1ce7c426..76ebb499f9 100644 --- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp +++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp @@ -866,7 +866,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags() QTreeWidgetItemIterator it(testWidget, iteratorflags); it += start; int iMatch = 0; - while (*it && iMatch < matches.count()) { + while (*it && iMatch < matches.size()) { QTreeWidgetItem *item = *it; QCOMPARE(item->text(0), matches[iMatch]); ++it; diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 1efdb3df59..2ceef58fac 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -153,11 +153,11 @@ void tst_QAction::alternateShortcuts() act.setAutoRepeat(true); QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); - QCOMPARE(spy.count(), 1); //act should have been triggered + QCOMPARE(spy.size(), 1); //act should have been triggered act.setAutoRepeat(false); QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); - QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time + QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time //end of the scope of the action, it will be destroyed and removed from wid //This action should also unregister its shortcuts @@ -187,12 +187,12 @@ void tst_QAction::keysequence() act.setAutoRepeat(true); QTest::keySequence(&testWidget, ks); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 1); // act should have been triggered + QCOMPARE(spy.size(), 1); // act should have been triggered act.setAutoRepeat(false); QTest::keySequence(&testWidget, ks); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time + QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time // end of the scope of the action, it will be destroyed and removed from widget // This action should also unregister its shortcuts @@ -228,15 +228,15 @@ void tst_QAction::enabledVisibleInteraction() act.setEnabled(true); act.setVisible(false); QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); - QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger + QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger act.setVisible(false); act.setEnabled(true); QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); - QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger + QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger act.setVisible(true); act.setEnabled(true); QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier); - QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger + QCOMPARE(spy.size(), 1); //act is visible and enabled, so trigger } #endif // QT_CONFIG(shortcut) @@ -254,12 +254,12 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QSignalSpy actionSpy(checkedAction, QOverload<bool>::of(&QAction::triggered)); QSignalSpy actionGroupSpy(&ag, QOverload<QAction*>::of(&QActionGroup::triggered)); - QCOMPARE(actionGroupSpy.count(), 0); - QCOMPARE(actionSpy.count(), 0); + QCOMPARE(actionGroupSpy.size(), 0); + QCOMPARE(actionSpy.size(), 0); checkedAction->trigger(); // check that both the group and the action have emitted the signal - QCOMPARE(actionGroupSpy.count(), 1); - QCOMPARE(actionSpy.count(), 1); + QCOMPARE(actionGroupSpy.size(), 1); + QCOMPARE(actionSpy.size(), 1); } #if QT_CONFIG(shortcut) @@ -282,7 +282,7 @@ void tst_QAction::repeat() act.setAutoRepeat(true); QTest::keyPress(&testWidget, Qt::Key_F); QTest::keyRelease(&testWidget, Qt::Key_F); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QTest::keyPress(&testWidget, Qt::Key_F); @@ -290,7 +290,7 @@ void tst_QAction::repeat() QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); QTest::keyRelease(&testWidget, Qt::Key_F); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); spy.clear(); act.setAutoRepeat(false); @@ -298,14 +298,14 @@ void tst_QAction::repeat() QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); QTest::keyRelease(&testWidget, Qt::Key_F); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); act.setAutoRepeat(true); QTest::keyPress(&testWidget, Qt::Key_F); QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true); QTest::keyRelease(&testWidget, Qt::Key_F); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QAction::disableShortcutsWithBlockedWidgets_data() @@ -355,7 +355,7 @@ void tst_QAction::disableShortcutsWithBlockedWidgets() QSignalSpy spy(&action, &QAction::triggered); QTest::keyPress(&window, Qt::Key_1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } class ShortcutOverrideWidget : public QWidget @@ -393,7 +393,7 @@ void tst_QAction::shortcutFromKeyEvent() // shortcut route for us QKeyEvent e(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier); QApplication::sendEvent(&testWidget, &e); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(testWidget.shortcutOverrideCount, 1); } @@ -432,42 +432,42 @@ void tst_QAction::disableShortcutInMenuAction() QKeyEvent event(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), ++expectedTriggerCount); + QCOMPARE(spy.size(), ++expectedTriggerCount); testMenu->menuAction()->setProperty(property, false); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), expectedTriggerCount); + QCOMPARE(spy.size(), expectedTriggerCount); testMenu->menuAction()->setProperty(property, true); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), ++expectedTriggerCount); + QCOMPARE(spy.size(), ++expectedTriggerCount); // If the action lives somewhere else, then keep firing even // if the menu has been hidden or disabled. toolBar->addAction(testAction); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), ++expectedTriggerCount); + QCOMPARE(spy.size(), ++expectedTriggerCount); testMenu->menuAction()->setProperty(property, false); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), ++expectedTriggerCount); + QCOMPARE(spy.size(), ++expectedTriggerCount); // unless all other widgets in which the action lives have // been hidden... toolBar->hide(); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), expectedTriggerCount); + QCOMPARE(spy.size(), expectedTriggerCount); // ... or disabled toolBar->show(); toolBar->setEnabled(false); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), expectedTriggerCount); + QCOMPARE(spy.size(), expectedTriggerCount); // back to normal toolBar->setEnabled(true); QApplication::sendEvent(&mw, &event); - QCOMPARE(spy.count(), ++expectedTriggerCount); + QCOMPARE(spy.size(), ++expectedTriggerCount); } #endif // QT_CONFIG(shortcut) diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index afcecd4637..39f59f1408 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -486,7 +486,7 @@ static char **QString2cstrings(const QString &args) static QByteArrayList cache; const auto &list = QStringView{ args }.split(' '); - auto argarray = new char*[list.count() + 1]; + auto argarray = new char*[list.size() + 1]; int i = 0; for (; i < list.size(); ++i ) { @@ -575,7 +575,7 @@ void tst_QApplication::lastWindowClosed() QTimer::singleShot(1000, dialog.data(), &QDialog::accept); dialog->exec(); QVERIFY(dialog); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QPointer<CloseWidget>widget = new CloseWidget; widget->setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("CloseWidget")); @@ -584,7 +584,7 @@ void tst_QApplication::lastWindowClosed() QObject::connect(&app, &QGuiApplication::lastWindowClosed, widget.data(), &QObject::deleteLater); QCoreApplication::exec(); QVERIFY(!widget); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); delete dialog; @@ -602,7 +602,7 @@ void tst_QApplication::lastWindowClosed() QTimer::singleShot(1000, &app, &QApplication::closeAllWindows); QCoreApplication::exec(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } class QuitOnLastWindowClosedDialog : public QDialog @@ -635,8 +635,8 @@ public slots: other.exec(); // verify that the eventloop ran and let the timer fire - QCOMPARE(spy.count(), 1); - QCOMPARE(appSpy.count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(appSpy.size(), 1); } private: @@ -661,7 +661,7 @@ public slots: timer1.setSingleShot(true); timer1.start(1000); dialog.exec(); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); show(); } @@ -682,7 +682,7 @@ void tst_QApplication::quitOnLastWindowClosed() QCoreApplication::exec(); // lastWindowClosed() signal should only be sent after the last dialog is closed - QCOMPARE(appSpy.count(), 2); + QCOMPARE(appSpy.size(), 2); } { int argc = 0; @@ -697,8 +697,8 @@ void tst_QApplication::quitOnLastWindowClosed() timer1.setSingleShot(true); timer1.start(1000); dialog.exec(); - QCOMPARE(spy1.count(), 1); - QCOMPARE(appSpy.count(), 0); + QCOMPARE(spy1.size(), 1); + QCOMPARE(appSpy.size(), 0); QTimer timer2; connect(&timer2, &QTimer::timeout, &app, &QCoreApplication::quit); @@ -707,8 +707,8 @@ void tst_QApplication::quitOnLastWindowClosed() timer2.start(1000); int returnValue = QCoreApplication::exec(); QCOMPARE(returnValue, 0); - QCOMPARE(spy2.count(), 1); - QCOMPARE(appSpy.count(), 0); + QCOMPARE(spy2.size(), 1); + QCOMPARE(appSpy.size(), 0); } { int argc = 0; @@ -739,8 +739,8 @@ void tst_QApplication::quitOnLastWindowClosed() QCoreApplication::exec(); - QCOMPARE(spy.count(), 1); - QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit + QCOMPARE(spy.size(), 1); + QVERIFY(spy2.size() < 15); // Should be around 10 if closing caused the quit } bool quitApplicationTriggered = false; @@ -770,7 +770,7 @@ void tst_QApplication::quitOnLastWindowClosed() QCoreApplication::exec(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(quitApplicationTriggered); } { @@ -792,8 +792,8 @@ void tst_QApplication::quitOnLastWindowClosed() QCOMPARE(returnValue, 0); // failure here means the timer above didn't fire, and the // quit was caused the dialog being closed (not the window) - QCOMPARE(timerSpy.count(), 1); - QCOMPARE(appSpy.count(), 2); + QCOMPARE(timerSpy.size(), 1); + QCOMPARE(appSpy.size(), 2); } { int argc = 0; @@ -842,7 +842,7 @@ void tst_QApplication::quitOnLastWindowClosed() QTimer::singleShot(100, &w1, &QWidget::close); QCoreApplication::exec(); - QVERIFY(timerSpy.count() < 10); + QVERIFY(timerSpy.size() < 10); } } @@ -930,8 +930,8 @@ void tst_QApplication::closeAllWindows() bool isPathListIncluded(const QStringList &l, const QStringList &r) { - int size = r.count(); - if (size > l.count()) + int size = r.size(); + if (size > l.size()) return false; #if defined (Q_OS_WIN) Qt::CaseSensitivity cs = Qt::CaseInsensitive; @@ -939,13 +939,13 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r) Qt::CaseSensitivity cs = Qt::CaseSensitive; #endif int i = 0, j = 0; - for ( ; i < l.count() && j < r.count(); ++i) { + for ( ; i < l.size() && j < r.size(); ++i) { if (QDir::toNativeSeparators(l[i]).compare(QDir::toNativeSeparators(r[j]), cs) == 0) { ++j; i = -1; } } - return j == r.count(); + return j == r.size(); } #if QT_CONFIG(library) @@ -1005,7 +1005,7 @@ void tst_QApplication::libraryPaths() { qCDebug(lcTests) << "Initial library path:" << QApplication::libraryPaths(); - int count = QApplication::libraryPaths().count(); + int count = QApplication::libraryPaths().size(); #if 0 // this test doesn't work if KDE 4 is installed QCOMPARE(count, 1); // before creating QApplication, only the PluginsPath is in the libraryPaths() @@ -1014,9 +1014,9 @@ void tst_QApplication::libraryPaths() QApplication::addLibraryPath(installPathPlugins); qCDebug(lcTests) << "installPathPlugins" << installPathPlugins; qCDebug(lcTests) << "After adding plugins path:" << QApplication::libraryPaths(); - QCOMPARE(QApplication::libraryPaths().count(), count); + QCOMPARE(QApplication::libraryPaths().size(), count); QApplication::addLibraryPath(testDir); - QCOMPARE(QApplication::libraryPaths().count(), count + 1); + QCOMPARE(QApplication::libraryPaths().size(), count + 1); // creating QApplication adds the applicationDirPath to the libraryPath int argc = 1; @@ -1026,19 +1026,19 @@ void tst_QApplication::libraryPaths() // On Windows CE these are identical and might also be the case for other // systems too if (appDirPath != installPathPlugins) - QCOMPARE(QApplication::libraryPaths().count(), count + 2); + QCOMPARE(QApplication::libraryPaths().size(), count + 2); } { int argc = 1; QApplication app(argc, &argv0); qCDebug(lcTests) << "Initial library path:" << QCoreApplication::libraryPaths(); - int count = QCoreApplication::libraryPaths().count(); + int count = QCoreApplication::libraryPaths().size(); QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath); QCoreApplication::addLibraryPath(installPathPlugins); qCDebug(lcTests) << "installPathPlugins" << installPathPlugins; qCDebug(lcTests) << "After adding plugins path:" << QCoreApplication::libraryPaths(); - QCOMPARE(QCoreApplication::libraryPaths().count(), count); + QCOMPARE(QCoreApplication::libraryPaths().size(), count); QString appDirPath = QCoreApplication::applicationDirPath(); @@ -1046,14 +1046,14 @@ void tst_QApplication::libraryPaths() QCoreApplication::addLibraryPath(appDirPath + "/.."); qCDebug(lcTests) << "appDirPath" << appDirPath; qCDebug(lcTests) << "After adding appDirPath && appDirPath + /..:" << QCoreApplication::libraryPaths(); - QCOMPARE(QCoreApplication::libraryPaths().count(), count + 1); + QCOMPARE(QCoreApplication::libraryPaths().size(), count + 1); #ifdef Q_OS_MACOS QCoreApplication::addLibraryPath(appDirPath + "/../MacOS"); #else QCoreApplication::addLibraryPath(appDirPath + "/tmp/.."); #endif qCDebug(lcTests) << "After adding appDirPath + /tmp/..:" << QCoreApplication::libraryPaths(); - QCOMPARE(QCoreApplication::libraryPaths().count(), count + 1); + QCOMPARE(QCoreApplication::libraryPaths().size(), count + 1); } } @@ -1153,7 +1153,7 @@ void SendPostedEventsTester::doTest() eventLoop.exec(); QVERIFY(p != nullptr); - QCOMPARE(eventSpy.count(), 2); + QCOMPARE(eventSpy.size(), 2); QCOMPARE(eventSpy.at(0), int(QEvent::MetaCall)); QCOMPARE(eventSpy.at(1), int(QEvent::User)); eventSpy.clear(); @@ -1656,22 +1656,22 @@ void tst_QApplication::focusChanged() hbox1.addWidget(&le1); hbox1.addWidget(&pb1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); parent1.show(); QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse) - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 2); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 2); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &le1); QCOMPARE(now, QApplication::focusWidget()); QVERIFY(!old); spy.clear(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); pb1.setFocus(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &pb1); @@ -1680,7 +1680,7 @@ void tst_QApplication::focusChanged() spy.clear(); lb1.setFocus(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &lb1); @@ -1689,7 +1689,7 @@ void tst_QApplication::focusChanged() spy.clear(); lb1.clearFocus(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(!now); @@ -1709,9 +1709,9 @@ void tst_QApplication::focusChanged() parent2.show(); QApplication::setActiveWindow(&parent2); // needs this on twm (focus follows mouse) - QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows - old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0)); - now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); + QVERIFY(spy.size() > 0); // one for deactivation, one for activation on Windows + old = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(0)); + now = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(1)); QCOMPARE(now, &le2); QCOMPARE(now, QApplication::focusWidget()); QVERIFY(!old); @@ -1736,10 +1736,10 @@ void tst_QApplication::focusChanged() tab.simulate(now); if (!tabAllControls) { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(now, QApplication::focusWidget()); } else { - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &pb2); @@ -1749,11 +1749,11 @@ void tst_QApplication::focusChanged() } if (!tabAllControls) { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(now, QApplication::focusWidget()); } else { tab.simulate(now); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &le2); @@ -1763,11 +1763,11 @@ void tst_QApplication::focusChanged() } if (!tabAllControls) { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(now, QApplication::focusWidget()); } else { backtab.simulate(now); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &pb2); @@ -1778,12 +1778,12 @@ void tst_QApplication::focusChanged() if (!tabAllControls) { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(now, QApplication::focusWidget()); old = &pb2; } else { backtab.simulate(now); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &le2); @@ -1794,10 +1794,10 @@ void tst_QApplication::focusChanged() click.simulate(old); if (!(pb2.focusPolicy() & Qt::ClickFocus)) { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(now, QApplication::focusWidget()); } else { - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &pb2); @@ -1806,7 +1806,7 @@ void tst_QApplication::focusChanged() spy.clear(); click.simulate(old); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QCOMPARE(now, &le2); @@ -1817,15 +1817,15 @@ void tst_QApplication::focusChanged() parent1.activateWindow(); QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse) - QVERIFY(spy.count() == 1 || spy.count() == 2); // one for deactivation, one for activation on Windows + QVERIFY(spy.size() == 1 || spy.size() == 2); // one for deactivation, one for activation on Windows //on windows, the change of focus is made in 2 steps //(the focusChanged SIGNAL is emitted twice) - if (spy.count()==1) - old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0)); + if (spy.size()==1) + old = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(0)); else - old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0)); - now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); + old = qvariant_cast<QWidget*>(spy.at(spy.size()-2).at(0)); + now = qvariant_cast<QWidget*>(spy.at(spy.size()-1).at(1)); QCOMPARE(now, &le1); QCOMPARE(now, QApplication::focusWidget()); QCOMPARE(old, &le2); @@ -2060,11 +2060,11 @@ void tst_QApplication::topLevelWidgets() #endif QCoreApplication::processEvents(); QVERIFY(QApplication::topLevelWidgets().contains(w)); - QCOMPARE(QApplication::topLevelWidgets().count(), 1); + QCOMPARE(QApplication::topLevelWidgets().size(), 1); delete w; w = nullptr; QCoreApplication::processEvents(); - QCOMPARE(QApplication::topLevelWidgets().count(), 0); + QCOMPARE(QApplication::topLevelWidgets().size(), 0); } @@ -2492,10 +2492,10 @@ void tst_QApplication::wheelEventPropagation() else ++hcount; QCoreApplication::processEvents(); - QCOMPARE(innerVSpy.count(), innerScrolls ? vcount : 0); - QCOMPARE(innerHSpy.count(), innerScrolls ? hcount : 0); - QCOMPARE(outerVSpy.count(), innerScrolls ? 0 : vcount); - QCOMPARE(outerHSpy.count(), innerScrolls ? 0 : hcount); + QCOMPARE(innerVSpy.size(), innerScrolls ? vcount : 0); + QCOMPARE(innerHSpy.size(), innerScrolls ? hcount : 0); + QCOMPARE(outerVSpy.size(), innerScrolls ? 0 : vcount); + QCOMPARE(outerHSpy.size(), innerScrolls ? 0 : hcount); } } diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 3a7f33228b..febb517638 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -517,14 +517,14 @@ void tst_QBoxLayout::testLayoutEngine() QHBoxLayout box; box.setSpacing(spacing); int i; - for (i = 0; i < itemDescriptions.count(); ++i) { + for (i = 0; i < itemDescriptions.size(); ++i) { Descr descr = itemDescriptions.at(i); LayoutItem *li = new LayoutItem(descr); box.addItem(li); box.setStretch(i, descr.stretch); } box.setGeometry(QRect(0,0,size,100)); - for (i = 0; i < expectedSizes.count(); ++i) { + for (i = 0; i < expectedSizes.size(); ++i) { int xSize = expectedSizes.at(i); int xPos = expectedPositions.at(i); QLayoutItem *item = box.itemAt(i); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 6b0d944c98..3871079da7 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -661,7 +661,7 @@ void tst_QGridLayout::spacingsAndMargins() QSKIP("The screen is too small to run this test case"); // We are relying on the order here... - for (int pi = 0; pi < sizehinters.count(); ++pi) { + for (int pi = 0; pi < sizehinters.size(); ++pi) { QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0)); QCOMPARE(pt, expectedpositions.at(pi)); } @@ -831,7 +831,7 @@ void tst_QGridLayout::minMaxSize() QList<QPointer<SizeHinterFrame> > sizehinters; for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { - SizeInfo si = sizeinfos.at(sizehinters.count()); + SizeInfo si = sizeinfos.at(sizehinters.size()); int numpixels = si.hfwNumPixels; if (pass == 1 && numpixels == -1) numpixels = -2; //### yuk, (and don't fake it if it already tests sizehint) @@ -860,7 +860,7 @@ void tst_QGridLayout::minMaxSize() QTRY_COMPARE(toplevel.size(), toplevel.sizeHint()); } // We are relying on the order here... - for (int pi = 0; pi < sizehinters.count(); ++pi) { + for (int pi = 0; pi < sizehinters.size(); ++pi) { QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0)); QCOMPARE(pt, sizeinfos.at(pi).expectedPos); } @@ -1030,7 +1030,7 @@ void tst_QGridLayout::styleDependentSpacingsAndMargins() widget.adjustSize(); QApplication::processEvents(); - for (int pi = 0; pi < expectedpositions.count(); ++pi) { + for (int pi = 0; pi < expectedpositions.size(); ++pi) { QCOMPARE(sizehinters.at(pi)->pos(), expectedpositions.at(pi)); } } @@ -1420,7 +1420,7 @@ void tst_QGridLayout::layoutSpacing() QLayout *layout = widget->layout(); QVERIFY(layout); - for (int pi = 0; pi < expectedpositions.count(); ++pi) { + for (int pi = 0; pi < expectedpositions.size(); ++pi) { QLayoutItem *item = layout->itemAt(pi); //qDebug() << item->widget()->pos(); QCOMPARE(item->widget()->pos(), expectedpositions.at(pi)); diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index b40e9f867d..17f007e8f8 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -1350,10 +1350,10 @@ void tst_QShortcut::keys() QCOMPARE(QApplication::focusWidget(), &le); QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Enter); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Return); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.size(), 2); } QTEST_MAIN(tst_QShortcut) diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp index 06e97e69b6..15651d44b3 100644 --- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp @@ -107,7 +107,7 @@ void tst_QStackedLayout::testCase() // One widget added to layout QWidget *w1 = new QWidget(testWidget); testLayout->addWidget(w1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), 0); spy.clear(); QCOMPARE(testLayout->currentIndex(), 0); @@ -124,7 +124,7 @@ void tst_QStackedLayout::testCase() // Change the current index testLayout->setCurrentIndex(1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), 1); spy.clear(); QCOMPARE(testLayout->currentIndex(), 1); @@ -138,7 +138,7 @@ void tst_QStackedLayout::testCase() // Second widget removed from layout; back to nothing testLayout->removeWidget(w2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), -1); spy.clear(); QCOMPARE(testLayout->currentIndex(), -1); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 5d615780a8..31205d7cd6 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -2781,7 +2781,7 @@ void tst_QWidget::resizePropagation() { // Capture count of latest async signals if (!checkCountIncrement) - count = spy.count(); + count = spy.size(); // Resize if required if (size.isValid()) @@ -2792,12 +2792,12 @@ void tst_QWidget::resizePropagation() // Check signal count and qDebug output for fail analysis if (checkCountIncrement) { - QTRY_VERIFY(spy.count() > count); - qDebug() << "spy count:" << spy.count() << "previous count:" << count; - count = spy.count(); + QTRY_VERIFY(spy.size() > count); + qDebug() << "spy count:" << spy.size() << "previous count:" << count; + count = spy.size(); } else { qDebug() << spy << widget.windowState() << window->windowState(); - QCOMPARE(spy.count(), count); + QCOMPARE(spy.size(), count); } // QTRY necessary because state changes are propagated async @@ -3296,7 +3296,7 @@ void tst_QWidget::reparent() void tst_QWidget::setScreen() { const auto screens = QApplication::screens(); - if (screens.count() < 2) + if (screens.size() < 2) QSKIP("This test tests nothing on a machine with a single screen."); QScreen *screen0 = screens.at(0); @@ -3690,7 +3690,7 @@ void tst_QWidget::raise() QObjectList list1{child1, child2, child3, child4}; QCOMPARE(parentPtr->children(), list1); - QCOMPARE(allChildren.count(), list1.count()); + QCOMPARE(allChildren.size(), list1.size()); for (UpdateWidget *child : qAsConst(allChildren)) { int expectedPaintEvents = child == child4 ? 1 : 0; @@ -3789,7 +3789,7 @@ void tst_QWidget::lower() QObjectList list1{child1, child2, child3, child4}; QCOMPARE(parent->children(), list1); - QCOMPARE(allChildren.count(), list1.count()); + QCOMPARE(allChildren.size(), list1.size()); for (UpdateWidget *child : qAsConst(allChildren)) { int expectedPaintEvents = child == child4 ? 1 : 0; @@ -4807,7 +4807,7 @@ protected: } public: QList<WId> m_winIdList; - int winIdChangeEventCount() const { return m_winIdList.count(); } + int winIdChangeEventCount() const { return m_winIdList.size(); } }; class CreateDestroyWidget : public WinIdChangeWidget @@ -6877,7 +6877,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation() QWidgetList widgets; widgets << &topLevelWidget << &topLevelChild << &dialog << &dialogChild; - QCOMPARE(widgets.count(), 4); + QCOMPARE(widgets.size(), 4); topLevelWidget.show(); dialog.show(); @@ -6906,7 +6906,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation() const QIcon windowIcon = qApp->style()->standardIcon(QStyle::SP_TitleBarMenuButton); qApp->setWindowIcon(windowIcon); - for (int i = 0; i < widgets.count(); ++i) { + for (int i = 0; i < widgets.size(); ++i) { // Check QEvent::ApplicationWindowIconChange EventSpyPtr spy = applicationEventSpies.at(i); QWidget *widget = spy->widget(); @@ -6923,7 +6923,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation() QCOMPARE(spy->count(), 1); spy->clear(); } - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < windows.size(); ++i) { // Check QEvent::ApplicationWindowIconChange (sent to QWindow) // QWidgetWindows don't get this event, since the widget takes care of changing the icon WindowEventSpyPtr spy = appWindowEventSpies.at(i); @@ -6941,7 +6941,7 @@ void tst_QWidget::testWindowIconChangeEventPropagation() // Set icon on a top-level widget. topLevelWidget.setWindowIcon(QIcon()); - for (int i = 0; i < widgets.count(); ++i) { + for (int i = 0; i < widgets.size(); ++i) { // Check QEvent::ApplicationWindowIconChange EventSpyPtr spy = applicationEventSpies.at(i); QCOMPARE(spy->count(), 0); @@ -12840,7 +12840,7 @@ void tst_QWidget::deleteWindowInCloseEvent() QApplication::exec(); // It should still result in a single lastWindowClosed emit - QCOMPARE(quitSpy.count(), 1); + QCOMPARE(quitSpy.size(), 1); } /*! @@ -12861,7 +12861,7 @@ void tst_QWidget::quitOnClose() widget->close(); }); QApplication::exec(); - QCOMPARE(quitSpy.count(), 1); + QCOMPARE(quitSpy.size(), 1); widget->show(); QVERIFY(QTest::qWaitForWindowExposed(widget.get())); @@ -12869,7 +12869,7 @@ void tst_QWidget::quitOnClose() widget.reset(); }); QApplication::exec(); - QCOMPARE(quitSpy.count(), 2); + QCOMPARE(quitSpy.size(), 2); } void tst_QWidget::setParentChangesFocus_data() diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 1594ebcda9..19cb8c2a81 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -1642,9 +1642,9 @@ void tst_QWidget_window::resetFocusObjectOnDestruction() widget->show(); QVERIFY(QTest::qWaitForWindowActive(widget.get())); - int activeCount = focusObjectChangedSpy.count(); + int activeCount = focusObjectChangedSpy.size(); widget.reset(); - QVERIFY(focusObjectChangedSpy.count() > activeCount); + QVERIFY(focusObjectChangedSpy.size() > activeCount); QCOMPARE(focusObjectChangedSpy.last().last().value<QObject*>(), nullptr); focusObjectChangedSpy.clear(); @@ -1657,10 +1657,10 @@ void tst_QWidget_window::resetFocusObjectOnDestruction() widget->show(); QVERIFY(QTest::qWaitForWindowActive(widget.get())); - activeCount = focusObjectChangedSpy.count(); + activeCount = focusObjectChangedSpy.size(); widget.reset(); // we might get more than one signal emission - QVERIFY(focusObjectChangedSpy.count() > activeCount); + QVERIFY(focusObjectChangedSpy.size() > activeCount); QCOMPARE(focusObjectChangedSpy.last().last().value<QObject*>(), nullptr); } diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp index 031856e0f9..0e0f84dbb1 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp @@ -222,7 +222,7 @@ void tst_QWidgetAction::customWidget() tb1.addAction(action); QList<QWidget *> combos = action->createdWidgets(); - QCOMPARE(combos.count(), 1); + QCOMPARE(combos.size(), 1); QPointer<QComboBox> combo1 = qobject_cast<QComboBox *>(combos.at(0)); QVERIFY(combo1); @@ -230,7 +230,7 @@ void tst_QWidgetAction::customWidget() tb2.addAction(action); combos = action->createdWidgets(); - QCOMPARE(combos.count(), 2); + QCOMPARE(combos.size(), 2); QCOMPARE(combos.at(0), combo1.data()); QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1)); diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index eb8f4bbda8..7cb4f4d132 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1707,7 +1707,7 @@ void tst_QStyleSheetStyle::toolTip() normalToolTip }; QWidgetList topLevels; - for (int i = 0; i < widgets.count() ; ++i) { + for (int i = 0; i < widgets.size() ; ++i) { QWidget *wid = widgets.at(i); QColor col = colors.at(i); diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 86dc47ec11..b33c819ee0 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -57,7 +57,7 @@ QString CsvCompleter::pathFromIndex(const QModelIndex &sourceIndex) const idx = parent.sibling(parent.row(), sourceIndex.column()); } while (idx.isValid()); - return list.count() == 1 ? list.constFirst() : list.join(QLatin1Char(',')); + return list.size() == 1 ? list.constFirst() : list.join(QLatin1Char(',')); } class tst_QCompleter : public QObject @@ -1176,10 +1176,10 @@ void tst_QCompleter::disabledItems() QAbstractItemView *view = lineEdit.completer()->popup(); QVERIFY(view->isVisible()); QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(0, 0)).center()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(view->isVisible()); QTest::mouseClick(view->viewport(), Qt::LeftButton, {}, view->visualRect(view->model()->index(1, 0)).center()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!view->isVisible()); } @@ -1193,7 +1193,7 @@ void tst_QCompleter::task178797_activatedOnReturn() auto completer = new QCompleter({"foobar1", "foobar2"}, &ledit); ledit.setCompleter(completer); QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated)); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); ledit.move(200, 200); ledit.show(); QApplication::setActiveWindow(&ledit); @@ -1205,7 +1205,7 @@ void tst_QCompleter::task178797_activatedOnReturn() QCoreApplication::processEvents(); QTest::keyClick(QApplication::activePopupWidget(), Qt::Key_Return); QCoreApplication::processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } class task189564_StringListModel : public QStringListModel @@ -1287,7 +1287,7 @@ void tst_QCompleter::task246056_setCompletionPrefix() QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down); QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down); QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Enter); // don't crash! - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); const auto index = spy.at(0).constFirst().toModelIndex(); QVERIFY(!index.isValid()); } @@ -1761,10 +1761,10 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() QTRY_VERIFY(cbox.completer()->popup()->isVisible()); QTest::keyClick(cbox.completer()->popup(), Qt::Key_Tab); QCOMPARE(cbox.completer()->currentCompletion(), QLatin1String("hux")); - QCOMPARE(activatedSpy.count(), 0); + QCOMPARE(activatedSpy.size(), 0); QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort); QCOMPARE(cbox.currentText(), QLatin1String("hux")); - QCOMPARE(activatedSpy.count(), 0); + QCOMPARE(activatedSpy.size(), 0); QVERIFY(!le->hasFocus()); } @@ -1805,7 +1805,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() QTRY_VERIFY(cbox.completer()->popup()->isVisible()); QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); - QTRY_COMPARE(activatedSpy.count(), 1); + QTRY_COMPARE(activatedSpy.size(), 1); // Navigate + enter activates only once (non-first item) cbox.lineEdit()->clear(); @@ -1815,7 +1815,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() QTRY_VERIFY(cbox.completer()->popup()->isVisible()); QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down); QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return); - QTRY_COMPARE(activatedSpy.count(), 1); + QTRY_COMPARE(activatedSpy.size(), 1); // Full text + enter activates only once cbox.lineEdit()->clear(); @@ -1824,7 +1824,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() QVERIFY(cbox.completer()->popup()); QTRY_VERIFY(cbox.completer()->popup()->isVisible()); QTest::keyClick(&cbox, Qt::Key_Return); - QTRY_COMPARE(activatedSpy.count(), 1); + QTRY_COMPARE(activatedSpy.size(), 1); } void tst_QCompleter::showPopupInGraphicsView() diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index 5348942857..2b04fc5104 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -110,7 +110,7 @@ void tst_QSystemTrayIcon::lastWindowClosed() QTimer::singleShot(2500, &window, SLOT(close())); QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails qApp->exec(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } QTEST_MAIN(tst_QSystemTrayIcon) diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index ec916925a3..533b91c608 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -516,24 +516,24 @@ void tst_QAbstractButton::animateClick() button.animateClick(); QVERIFY(button.isDown()); - QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(releasedSpy.count(), 0); - QCOMPARE(clickedSpy.count(), 0); + QCOMPARE(pressedSpy.size(), 1); + QCOMPARE(releasedSpy.size(), 0); + QCOMPARE(clickedSpy.size(), 0); qApp->processEvents(QEventLoop::AllEvents, 10); // QAbstractButton starts a 100ms timer which performs the click. If it // took more than 100ms to get here, then the button might no longer be down. if (elapsed.elapsed() < 100) { QVERIFY(button.isDown()); - QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(releasedSpy.count(), 0); - QCOMPARE(clickedSpy.count(), 0); + QCOMPARE(pressedSpy.size(), 1); + QCOMPARE(releasedSpy.size(), 0); + QCOMPARE(clickedSpy.size(), 0); } QTRY_VERIFY(!button.isDown()); // but once the button has been clicked, it must have taken at least 100ms QVERIFY(elapsed.elapsed() >= 100); - QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(releasedSpy.count(), 1); - QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(pressedSpy.size(), 1); + QCOMPARE(releasedSpy.size(), 1); + QCOMPARE(clickedSpy.size(), 1); } #if QT_CONFIG(shortcut) @@ -556,9 +556,9 @@ void tst_QAbstractButton::shortcutEvents() QTest::qWait(1000); // ensure animate timer is expired - QCOMPARE(pressedSpy.count(), 3); - QCOMPARE(releasedSpy.count(), 3); - QCOMPARE(clickedSpy.count(), 3); + QCOMPARE(pressedSpy.size(), 3); + QCOMPARE(releasedSpy.size(), 3); + QCOMPARE(clickedSpy.size(), 3); } #endif // QT_CONFIG(shortcut) @@ -600,14 +600,14 @@ void tst_QAbstractButton::mouseReleased() // QTBUG-53244 QSignalSpy spyRelease(&button, &QAbstractButton::released); QTest::mousePress(&button, Qt::LeftButton); - QCOMPARE(spyPress.count(), 1); + QCOMPARE(spyPress.size(), 1); QCOMPARE(button.isDown(), true); - QCOMPARE(spyRelease.count(), 0); + QCOMPARE(spyRelease.size(), 0); QTest::mouseClick(&button, Qt::RightButton); - QCOMPARE(spyPress.count(), 1); + QCOMPARE(spyPress.size(), 1); QCOMPARE(button.isDown(), true); - QCOMPARE(spyRelease.count(), 0); + QCOMPARE(spyRelease.size(), 0); QPointF posOutOfWidget = QPointF(30, 30); QMouseEvent me(QEvent::MouseMove, @@ -617,9 +617,9 @@ void tst_QAbstractButton::mouseReleased() // QTBUG-53244 qApp->sendEvent(&button, &me); // should emit released signal once mouse is dragging out of boundary - QCOMPARE(spyPress.count(), 1); + QCOMPARE(spyPress.size(), 1); QCOMPARE(button.isDown(), false); - QCOMPARE(spyRelease.count(), 1); + QCOMPARE(spyRelease.size(), 1); } #ifdef QT_KEYPAD_NAVIGATION @@ -684,7 +684,7 @@ void tst_QAbstractButton::buttonPressKeys() const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme() ->themeHint(QPlatformTheme::ButtonPressKeys) .value<QList<Qt::Key>>(); - for (uint i = 0; i < buttonPressKeys.length(); ++i) { + for (uint i = 0; i < buttonPressKeys.size(); ++i) { QTest::keyClick(testWidget, buttonPressKeys[i]); QCOMPARE(click_count, i + 1); } diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index edca1954fd..17caa091c6 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -1459,7 +1459,7 @@ void tst_QAbstractSlider::keyPressed() slider->setOrientation(Qt::Horizontal); slider->setInvertedAppearance(invertedAppearance); slider->setInvertedControls(invertedControls); - for (int i=0;i<keySequence.count();i++) { + for (int i=0;i<keySequence.size();i++) { QTest::keyClick(slider, keySequence.at(i)); } QCOMPARE(slider->sliderPosition(), expectedSliderPosition); @@ -1666,8 +1666,8 @@ void tst_QAbstractSlider::wheelEvent() #endif QCOMPARE(slider->sliderPosition(),expectedSliderPosition); int expectedSignalCount = (initialSliderPosition == expectedSliderPosition) ? 0 : 1; - QCOMPARE(spy1.count(), expectedSignalCount); - QCOMPARE(spy2.count(), expectedSignalCount); + QCOMPARE(spy1.size(), expectedSignalCount); + QCOMPARE(spy2.size(), expectedSignalCount); if (expectedSignalCount) QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp); } @@ -1814,9 +1814,9 @@ void tst_QAbstractSlider::sliderPressedReleased() QTest::mousePress(slider, Qt::LeftButton, {}, QPoint(rect.center().x() + 2, rect.center().y() + 2)); - QCOMPARE(spy1.count(), expectedCount); + QCOMPARE(spy1.size(), expectedCount); QTest::mouseRelease(slider, Qt::LeftButton, {}, rect.center()); - QCOMPARE(spy2.count(), expectedCount); + QCOMPARE(spy2.size(), expectedCount); delete slider; } @@ -1885,7 +1885,7 @@ void tst_QAbstractSlider::sliderMoved() slider->setMaximum(maximum); slider->setSliderDown(sliderDown); slider->setSliderPosition(position); - QCOMPARE(spy.count(), expectedCount); + QCOMPARE(spy.size(), expectedCount); delete slider; } @@ -1957,7 +1957,7 @@ void tst_QAbstractSlider::rangeChanged() slider.setRange(minimum, maximum); QSignalSpy spy(&slider, SIGNAL(rangeChanged(int,int))); slider.setRange(newMin, newMax); - QCOMPARE(spy.count(), expectedCount); + QCOMPARE(spy.size(), expectedCount); } void tst_QAbstractSlider::setSliderPosition_data() @@ -1996,8 +1996,8 @@ void tst_QAbstractSlider::setSliderPosition() QSignalSpy spy2(slider, SIGNAL(valueChanged(int))); slider->setSliderPosition(targetPosition); QCOMPARE(slider->sliderPosition(), targetPosition); - QCOMPARE(spy1.count(), down ? 1 : 0); - QCOMPARE(spy2.count(), tracking ? 1 : 0); + QCOMPARE(spy1.size(), down ? 1 : 0); + QCOMPARE(spy2.size(), tracking ? 1 : 0); QCOMPARE(slider->value(), tracking ? targetPosition : initialValue); if (tracking && down) QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp); @@ -2025,9 +2025,9 @@ void tst_QAbstractSlider::setValue() QSignalSpy spy2(slider, SIGNAL(valueChanged(int))); QSignalSpy spy3(slider, SIGNAL(actionTriggered(int))); slider->setValue(50); - QCOMPARE(spy1.count(), down ? 1 : 0); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 0); + QCOMPARE(spy1.size(), down ? 1 : 0); + QCOMPARE(spy2.size(), 1); + QCOMPARE(spy3.size(), 0); QCOMPARE(slider->value(), reportedValue); QCOMPARE(slider->sliderPosition(), reportedSliderPosition); if (down) @@ -2051,37 +2051,37 @@ void tst_QAbstractSlider::setRepeatAction() // Start repeat action with initial delay of 500 ms, and then repeating // every 250 ms. slider->setRepeatAction(QAbstractSlider::SliderPageStepAdd, 500, 250); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(slider->value(), 55); QElapsedTimer t; t.start(); QTest::qWait(300); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(slider->value(), 55); waitUntilTimeElapsed(t, 550); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(slider->value(), 65); QCOMPARE(spy.at(0).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd); waitUntilTimeElapsed(t, 790); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.size(), 2); QCOMPARE(slider->value(), 75); QCOMPARE(spy.at(1).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd); waitUntilTimeElapsed(t, 1790); - QTRY_COMPARE(spy.count(), 6); + QTRY_COMPARE(spy.size(), 6); QCOMPARE(slider->value(), 115); QCOMPARE(spy.at(4).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd); QCOMPARE(spy.at(5).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd); slider->setRepeatAction(QAbstractSlider::SliderNoAction); - QCOMPARE(spy.count(), 6); + QCOMPARE(spy.size(), 6); QCOMPARE(slider->value(), 115); QTest::qWait(300); - QCOMPARE(spy.count(), 6); + QCOMPARE(spy.size(), 6); QCOMPARE(slider->value(), 115); } diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index f95f017d6b..c8151a3b24 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -349,17 +349,17 @@ void tst_QButtonGroup::testSignals() pb1.animateClick(); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(clickedIdSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); + QCOMPARE(clickedIdSpy.size(), 1); int expectedId = -2; QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId); - QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(pressedIdSpy.count(), 1); + QCOMPARE(pressedSpy.size(), 1); + QCOMPARE(pressedIdSpy.size(), 1); QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId); - QCOMPARE(releasedSpy.count(), 1); - QCOMPARE(releasedIdSpy.count(), 1); + QCOMPARE(releasedSpy.size(), 1); + QCOMPARE(releasedIdSpy.size(), 1); QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId); clickedSpy.clear(); @@ -372,14 +372,14 @@ void tst_QButtonGroup::testSignals() pb2.animateClick(); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(clickedIdSpy.count(), 1); + QCOMPARE(clickedSpy.size(), 1); + QCOMPARE(clickedIdSpy.size(), 1); QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23); - QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(pressedIdSpy.count(), 1); + QCOMPARE(pressedSpy.size(), 1); + QCOMPARE(pressedIdSpy.size(), 1); QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23); - QCOMPARE(releasedSpy.count(), 1); - QCOMPARE(releasedIdSpy.count(), 1); + QCOMPARE(releasedSpy.size(), 1); + QCOMPARE(releasedIdSpy.size(), 1); QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23); @@ -389,18 +389,18 @@ void tst_QButtonGroup::testSignals() pb1.setCheckable(true); pb2.setCheckable(true); pb1.toggle(); - QCOMPARE(toggledSpy.count(), 1); - QCOMPARE(toggledIdSpy.count(), 1); + QCOMPARE(toggledSpy.size(), 1); + QCOMPARE(toggledIdSpy.size(), 1); pb2.toggle(); - QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled - QCOMPARE(toggledIdSpy.count(), 3); + QCOMPARE(toggledSpy.size(), 3); // equals 3 since pb1 and pb2 are both toggled + QCOMPARE(toggledIdSpy.size(), 3); pb1.setCheckable(false); pb2.setCheckable(false); pb1.toggle(); - QCOMPARE(toggledSpy.count(), 3); - QCOMPARE(toggledIdSpy.count(), 3); + QCOMPARE(toggledSpy.size(), 3); + QCOMPARE(toggledIdSpy.size(), 3); } void tst_QButtonGroup::task106609() @@ -440,7 +440,7 @@ void tst_QButtonGroup::task106609() radio1->setChecked(true); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); } void tst_QButtonGroup::checkedButton() @@ -525,7 +525,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() // NOTE: Reintroducing the bug of this task will cause the following line to crash: QTest::mouseClick(button, Qt::LeftButton); - QCOMPARE(spy1.count(), signalCount); + QCOMPARE(spy1.size(), signalCount); } void tst_QButtonGroup::autoIncrementId() diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp index 064b539f22..31da429a8f 100644 --- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp @@ -84,7 +84,7 @@ void tst_QCalendarWidget::getSetCheck() QDate selectedDate(2005, 7, 3); QSignalSpy spy(&object, SIGNAL(selectionChanged())); object.setSelectedDate(selectedDate); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(selectedDate, object.selectedDate()); //month and year object.setCurrentPage(2004, 1); diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp index b0b34ee3fa..7a54a6e5e6 100644 --- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp +++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp @@ -208,10 +208,10 @@ void tst_QCheckBox::stateChanged() QCoreApplication::processEvents(); QCOMPARE(cur_state, 1); - QCOMPARE(stateChangedSpy.count(), 3); + QCOMPARE(stateChangedSpy.size(), 3); testWidget.setCheckState(Qt::PartiallyChecked); QCoreApplication::processEvents(); - QCOMPARE(stateChangedSpy.count(), 3); + QCOMPARE(stateChangedSpy.size(), 3); } void tst_QCheckBox::isToggleButton() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 4ca3a1b5a5..87e44ff068 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -747,7 +747,7 @@ void tst_QComboBox::insertPolicy() testWidget->setInsertPolicy(insertPolicy); testWidget->addItems(initialEntries); testWidget->setEditable(true); - if (initialEntries.count() > 0) + if (initialEntries.size() > 0) testWidget->setCurrentIndex(currentIndex); // clear @@ -759,10 +759,10 @@ void tst_QComboBox::insertPolicy() // First check that there is the right number of entries, or // we may unwittingly pass - QCOMPARE((int)result.count(), testWidget->count()); + QCOMPARE((int)result.size(), testWidget->count()); // No need to compare if there are no strings to compare - if (result.count() > 0) { + if (result.size() > 0) { for (int i=0; i<testWidget->count(); ++i) { QCOMPARE(testWidget->itemText(i), result.at(i)); } @@ -859,18 +859,18 @@ void tst_QComboBox::autoCompletionCaseSensitivity() QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aww")); - QCOMPARE(spyReturn.count(), 0); + QCOMPARE(spyReturn.size(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_B); qApp->processEvents(); // autocompletions preserve userkey-case from 4.2 QCOMPARE(testWidget->currentText(), QString("abCDEF")); - QCOMPARE(spyReturn.count(), 0); + QCOMPARE(spyReturn.size(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case - QCOMPARE(spyReturn.count(), 1); + QCOMPARE(spyReturn.size(), 1); testWidget->clearEditText(); QTest::keyClick(testWidget->lineEdit(), 'c'); @@ -1169,7 +1169,7 @@ void tst_QComboBox::currentIndex() foreach(QString text, initialItems) { testWidget->addItem(text); } - QCOMPARE(testWidget->count(), initialItems.count()); + QCOMPARE(testWidget->count(), initialItems.size()); // set current index, remove and/or insert if (setCurrentIndex >= -1) { @@ -1187,11 +1187,11 @@ void tst_QComboBox::currentIndex() QCOMPARE(testWidget->currentText(), expectedCurrentText); // check that signal count is correct - QCOMPARE(indexChangedInt.count(), expectedSignalCount); + QCOMPARE(indexChangedInt.size(), expectedSignalCount); // compare with last sent signal values - if (indexChangedInt.count()) - QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(), + if (indexChangedInt.size()) + QCOMPARE(indexChangedInt.at(indexChangedInt.size() - 1).at(0).toInt(), testWidget->currentIndex()); if (edit) { @@ -1228,8 +1228,8 @@ void tst_QComboBox::insertItems_data() QTest::newRow("prepend") << initialItems << insertedItems << 0 << 0; QTest::newRow("prepend with negative value") << initialItems << insertedItems << -1 << 0; - QTest::newRow("append") << initialItems << insertedItems << initialItems.count() << initialItems.count(); - QTest::newRow("append with too high value") << initialItems << insertedItems << 999 << initialItems.count(); + QTest::newRow("append") << initialItems << insertedItems << initialItems.size() << initialItems.size(); + QTest::newRow("append with too high value") << initialItems << insertedItems << 999 << initialItems.size(); QTest::newRow("insert") << initialItems << insertedItems << 1 << 1; } @@ -1245,12 +1245,12 @@ void tst_QComboBox::insertItems() QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QComboBox *testWidget = topLevel.comboBox(); testWidget->insertItems(0, initialItems); - QCOMPARE(testWidget->count(), initialItems.count()); + QCOMPARE(testWidget->count(), initialItems.size()); testWidget->insertItems(insertIndex, insertedItems); - QCOMPARE(testWidget->count(), initialItems.count() + insertedItems.count()); - for (int i=0; i<insertedItems.count(); ++i) + QCOMPARE(testWidget->count(), initialItems.size() + insertedItems.size()); + for (int i=0; i<insertedItems.size(); ++i) QCOMPARE(testWidget->itemText(expectedIndex + i), insertedItems.at(i)); } @@ -1287,14 +1287,14 @@ void tst_QComboBox::insertItem() QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QComboBox *testWidget = topLevel.comboBox(); testWidget->insertItems(0, initialItems); - QCOMPARE(testWidget->count(), initialItems.count()); + QCOMPARE(testWidget->count(), initialItems.size()); testWidget->setEditable(true); if (editable) testWidget->setEditText("FOO"); testWidget->insertItem(insertIndex, itemLabel); - QCOMPARE(testWidget->count(), initialItems.count() + 1); + QCOMPARE(testWidget->count(), initialItems.size() + 1); QCOMPARE(testWidget->itemText(expectedIndex), itemLabel); if (editable) @@ -1362,21 +1362,21 @@ void tst_QComboBox::textpixmapdata() QFETCH(IconList, icons); QFETCH(VariantList, variant); - QVERIFY(text.count() == icons.count() && text.count() == variant.count()); + QVERIFY(text.size() == icons.size() && text.size() == variant.size()); TestWidget topLevel; topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QComboBox *testWidget = topLevel.comboBox(); - for (int i = 0; i<text.count(); ++i) { + for (int i = 0; i<text.size(); ++i) { testWidget->insertItem(i, text.at(i)); testWidget->setItemIcon(i, icons.at(i)); testWidget->setItemData(i, variant.at(i), Qt::UserRole); } - QCOMPARE(testWidget->count(), text.count()); + QCOMPARE(testWidget->count(), text.size()); - for (int i = 0; i<text.count(); ++i) { + for (int i = 0; i<text.size(); ++i) { QIcon icon = testWidget->itemIcon(i); QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey()); QPixmap original = icons.at(i).pixmap(1024); @@ -1384,7 +1384,7 @@ void tst_QComboBox::textpixmapdata() QCOMPARE(pixmap.toImage(), original.toImage()); } - for (int i = 0; i<text.count(); ++i) { + for (int i = 0; i<text.size(); ++i) { QCOMPARE(testWidget->itemText(i), text.at(i)); // ### we should test icons/pixmap as well, but I need to fix the api mismatch first QCOMPARE(testWidget->itemData(i, Qt::UserRole), variant.at(i)); @@ -1494,7 +1494,7 @@ void tst_QComboBox::currentTextChanged() QCOMPARE(testWidget->currentIndex(), 0); spy.clear(); testWidget->setCurrentText(QString("bar")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("bar")); // set text not in list @@ -1503,10 +1503,10 @@ void tst_QComboBox::currentTextChanged() spy.clear(); testWidget->setCurrentText(QString("qt")); if (editable) { - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("qt")); } else { - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } // item changed @@ -1514,12 +1514,12 @@ void tst_QComboBox::currentTextChanged() QCOMPARE(testWidget->currentIndex(), 0); spy.clear(); testWidget->setItemText(0, QString("ape")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("ape")); // change it back spy.clear(); testWidget->setItemText(0, QString("foo")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("foo")); } @@ -1544,13 +1544,13 @@ void tst_QComboBox::editTextChanged() QCOMPARE(testWidget->currentIndex(), 0); testWidget->setCurrentIndex(0); QCOMPARE(testWidget->currentIndex(), 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // no signal should be sent when changing to other index because we are not editable QCOMPARE(testWidget->currentIndex(), 0); testWidget->setCurrentIndex(1); QCOMPARE(testWidget->currentIndex(), 1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // now set to editable and reset current index testWidget->setEditable(true); @@ -1562,20 +1562,20 @@ void tst_QComboBox::editTextChanged() QCOMPARE(testWidget->currentIndex(), 0); testWidget->setCurrentIndex(0); QCOMPARE(testWidget->currentIndex(), 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // signal should be sent when changing to other index QCOMPARE(testWidget->currentIndex(), 0); testWidget->setCurrentIndex(1); QCOMPARE(testWidget->currentIndex(), 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<QString>(spy.at(0).at(0)), QString("bar")); // insert some keys and notice they are all signaled spy.clear(); QTest::keyClicks(testWidget, "bingo"); - QCOMPARE(spy.count(), 5); + QCOMPARE(spy.size(), 5); QCOMPARE(qvariant_cast<QString>(spy.at(4).at(0)), QString("barbingo")); } @@ -1742,7 +1742,7 @@ void tst_QComboBox::setMaxCount() // insert 5 items at pos 2. Make sure only two get inserted QSignalSpy spy(box.model(), SIGNAL(rowsInserted(QModelIndex,int,int))); box.insertItems(2, items); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(1).toInt(), 2); QCOMPARE(spy.at(0).at(2).toInt(), 3); @@ -2016,7 +2016,7 @@ void tst_QComboBox::flaggedItems() if (editable) comboBox.lineEdit()->selectAll(); - for (int i = 0; i < keyMovementList.count(); ++i) { + for (int i = 0; i < keyMovementList.size(); ++i) { Qt::Key key = keyMovementList[i]; QTest::keyClick(&comboBox, key); } @@ -2237,7 +2237,7 @@ void tst_QComboBox::separatorItem() box.addItems(items); foreach(int index, separators) box.insertSeparator(index); - QCOMPARE(box.count(), (items.count() + separators.count())); + QCOMPARE(box.count(), (items.size() + separators.size())); for (int i = 0, s = 0; i < box.count(); ++i) { if (i == separators.at(s)) { QCOMPARE(box.itemText(i), QString()); @@ -2445,7 +2445,7 @@ void tst_QComboBox::task247863_keyBoardSelection() QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter); QCOMPARE(combo.currentText(), QLatin1String("222")); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QComboBox::task220195_keyBoardSelection2() @@ -2720,16 +2720,16 @@ void tst_QComboBox::resetModel() QComboBox cb; StringListModel model({"1", "2"}); QSignalSpy spy(&cb, &QComboBox::currentIndexChanged); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QCOMPARE(cb.currentIndex(), -1); //no selection cb.setModel(&model); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(cb.currentIndex(), 0); //first item selected model.reset(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QCOMPARE(cb.currentIndex(), 0); //first item selected } @@ -2810,10 +2810,10 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() QApplication::processEvents(); QTRY_VERIFY(cb.hasFocus()); QTest::keyClick(static_cast<QWidget *>(0), '1'); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); edit.setFocus(); QTRY_VERIFY(edit.hasFocus()); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); } void tst_QComboBox::maxVisibleItems_data() @@ -3231,11 +3231,11 @@ void tst_QComboBox::respectChangedOwnershipOfItemView() QTableView *v2 = new QTableView(&box1); box1.setView(v2); // Here we do not expect v1 to be deleted QApplication::processEvents(); - QCOMPARE(spy1.count(), 0); + QCOMPARE(spy1.size(), 0); QSignalSpy spy2(v2, SIGNAL(destroyed())); box1.setView(v1); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); } void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() @@ -3263,7 +3263,7 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() if (scroller->isVisible()) { QSignalSpy doScrollSpy(scroller, SIGNAL(doScroll(int))); QTest::mouseMove(scroller, QPoint(5, 5), 500); - QTRY_VERIFY(doScrollSpy.count() > 0); + QTRY_VERIFY(doScrollSpy.size() > 0); } } } @@ -3420,7 +3420,7 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex() cbox.setCompleter(completer); QSignalSpy spy(&cbox, SIGNAL(activated(int))); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); cbox.move(200, 200); cbox.show(); QApplication::setActiveWindow(&cbox); @@ -3584,7 +3584,7 @@ void tst_QComboBox::buttonPressKeys() const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme() ->themeHint(QPlatformTheme::ButtonPressKeys) .value<QList<Qt::Key>>(); - for (int i = 0; i < buttonPressKeys.length(); ++i) { + for (int i = 0; i < buttonPressKeys.size(); ++i) { QTest::keyClick(&comboBox, buttonPressKeys[i]); // On some platforms, a window will not be immediately visible, // but take some event-loop iterations to complete. @@ -3614,11 +3614,11 @@ void tst_QComboBox::clearModel() model.setStringList({}); - QCOMPARE(indexSpy.count(), 1); + QCOMPARE(indexSpy.size(), 1); const int index = indexSpy.takeFirst().at(0).toInt(); QCOMPARE(index, -1); - QCOMPARE(textSpy.count(), 1); + QCOMPARE(textSpy.size(), 1); const QString text = textSpy.takeFirst().at(0).toString(); QCOMPARE(text, QString()); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 5f09eca8ad..972934a4ce 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -1159,7 +1159,7 @@ void tst_QDateTimeEdit::enterKey() // we include this test so a change to the behaviour can't go unnoticed. QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(QDate))); QTest::keyClick(testWidget, Qt::Key_Enter); - QCOMPARE(enterSpy.count(), 1); + QCOMPARE(enterSpy.size(), 1); QVariantList list = enterSpy.takeFirst(); QCOMPARE(list.at(0).toDate(), QDate(2004, 5, 9)); } @@ -2234,7 +2234,7 @@ void tst_QDateTimeEdit::dateSignalChecking() QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime))); testWidget->setDate(newDate); - QCOMPARE(dateSpy.count(), timesEmitted); + QCOMPARE(dateSpy.size(), timesEmitted); if (timesEmitted > 0) { QList<QVariant> list = dateSpy.takeFirst(); @@ -2242,8 +2242,8 @@ void tst_QDateTimeEdit::dateSignalChecking() d = qvariant_cast<QDate>(list.at(0)); QCOMPARE(d, newDate); } - QCOMPARE(dateTimeSpy.count(), timesEmitted); - QCOMPARE(timeSpy.count(), 0); + QCOMPARE(dateTimeSpy.size(), timesEmitted); + QCOMPARE(timeSpy.size(), 0); } void tst_QDateTimeEdit::timeSignalChecking_data() @@ -2270,7 +2270,7 @@ void tst_QDateTimeEdit::timeSignalChecking() QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime))); testWidget->setTime(newTime); - QCOMPARE(timeSpy.count(), timesEmitted); + QCOMPARE(timeSpy.size(), timesEmitted); if (timesEmitted > 0) { QList<QVariant> list = timeSpy.takeFirst(); @@ -2278,8 +2278,8 @@ void tst_QDateTimeEdit::timeSignalChecking() t = qvariant_cast<QTime>(list.at(0)); QCOMPARE(t, newTime); } - QCOMPARE(dateTimeSpy.count(), timesEmitted); - QCOMPARE(dateSpy.count(), 0); + QCOMPARE(dateTimeSpy.size(), timesEmitted); + QCOMPARE(dateSpy.size(), 0); } void tst_QDateTimeEdit::dateTimeSignalChecking_data() @@ -2320,7 +2320,7 @@ void tst_QDateTimeEdit::dateTimeSignalChecking() QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime))); testWidget->setDateTime(newDateTime); - QCOMPARE(dateSpy.count(), timesDateEmitted); + QCOMPARE(dateSpy.size(), timesDateEmitted); if (timesDateEmitted > 0) { QCOMPARE(timesDateEmitted, 1); QList<QVariant> list = dateSpy.takeFirst(); @@ -2328,14 +2328,14 @@ void tst_QDateTimeEdit::dateTimeSignalChecking() d = qvariant_cast<QDate>(list.at(0)); QCOMPARE(d, newDateTime.date()); } - QCOMPARE(timeSpy.count(), timesTimeEmitted); + QCOMPARE(timeSpy.size(), timesTimeEmitted); if (timesTimeEmitted > 0) { QList<QVariant> list = timeSpy.takeFirst(); QTime t; t = qvariant_cast<QTime>(list.at(0)); QCOMPARE(t, newDateTime.time()); } - QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted); + QCOMPARE(dateTimeSpy.size(), timesDateTimeEmitted); if (timesDateTimeEmitted > 0) { QList<QVariant> list = dateTimeSpy.takeFirst(); QDateTime dt; @@ -3199,22 +3199,22 @@ void tst_QDateTimeEdit::task149097() testWidget->setDisplayFormat("yyyy/MM/dd hh:mm:ss"); testWidget->setDateTime(QDateTime(QDate(2001, 02, 03), QTime(5, 1, 2))); // QTest::keyClick(testWidget, Qt::Key_Enter); - QCOMPARE(dtSpy.count(), 1); - QCOMPARE(dSpy.count(), 1); - QCOMPARE(tSpy.count(), 1); + QCOMPARE(dtSpy.size(), 1); + QCOMPARE(dSpy.size(), 1); + QCOMPARE(tSpy.size(), 1); testWidget->setCurrentSection(QDateTimeEdit::YearSection); testWidget->stepBy(1); - QCOMPARE(dtSpy.count(), 2); - QCOMPARE(dSpy.count(), 2); - QCOMPARE(tSpy.count(), 1); + QCOMPARE(dtSpy.size(), 2); + QCOMPARE(dSpy.size(), 2); + QCOMPARE(tSpy.size(), 1); testWidget->setCurrentSection(QDateTimeEdit::MinuteSection); testWidget->stepBy(1); - QCOMPARE(dtSpy.count(), 3); - QCOMPARE(dSpy.count(), 2); - QCOMPARE(tSpy.count(), 2); + QCOMPARE(dtSpy.size(), 3); + QCOMPARE(dSpy.size(), 2); + QCOMPARE(tSpy.size(), 2); } void tst_QDateTimeEdit::task148725() @@ -4592,12 +4592,12 @@ void tst_QDateTimeEdit::stepModifierPressAndHold() QStyle::CC_SpinBox, &spinBoxStyleOption, subControl, &edit); QTest::mousePress(&edit, Qt::LeftButton, modifiers, buttonRect.center()); - QTRY_VERIFY(spy.length() >= 3); + QTRY_VERIFY(spy.size() >= 3); QTest::mouseRelease(&edit, Qt::LeftButton, modifiers, buttonRect.center()); const auto value = spy.last().at(0); QVERIFY(value.userType() == QMetaType::QDate); - const QDate expectedDate = startDate.addYears(spy.length() * + const QDate expectedDate = startDate.addYears(spy.size() * expectedStepModifier); QCOMPARE(value.toDate(), expectedDate); } diff --git a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp index 3008714576..1d8c970ef4 100644 --- a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp +++ b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp @@ -52,14 +52,14 @@ void tst_QDial::valueChanged() dial.setMaximum(100); QSignalSpy spy(&dial, SIGNAL(valueChanged(int))); dial.setValue(50); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); dial.setValue(25); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); // repeat! dial.setValue(25); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QDial::sliderMoved() @@ -88,8 +88,8 @@ void tst_QDial::sliderMoved() QMouseEvent moveevent(QEvent::MouseMove, init, dial.mapToGlobal(init), Qt::LeftButton, Qt::LeftButton, {}); qApp->sendEvent(&dial, &moveevent); - QCOMPARE( sliderspy.count(), 1); - QCOMPARE( valuespy.count(), 0); + QCOMPARE( sliderspy.size(), 1); + QCOMPARE( valuespy.size(), 0); } @@ -98,14 +98,14 @@ void tst_QDial::sliderMoved() QMouseEvent moveevent(QEvent::MouseMove, init, dial.mapToGlobal(init), Qt::LeftButton, Qt::LeftButton, {}); qApp->sendEvent(&dial, &moveevent); - QCOMPARE( sliderspy.count(), 2); - QCOMPARE( valuespy.count(), 0); + QCOMPARE( sliderspy.size(), 2); + QCOMPARE( valuespy.size(), 0); } QMouseEvent releaseevent(QEvent::MouseButtonRelease, init, dial.mapToGlobal(init), Qt::LeftButton, Qt::LeftButton, {}); qApp->sendEvent(&dial, &releaseevent); - QCOMPARE( valuespy.count(), 1); // valuechanged signal should be called at this point + QCOMPARE( valuespy.size(), 1); // valuechanged signal should be called at this point } diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index c2a9f27295..df26b4c5da 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -97,7 +97,7 @@ void tst_QDialogButtonBox::testConstructor1() QDialogButtonBox buttonbox; QCOMPARE(buttonbox.orientation(), Qt::Horizontal); - QCOMPARE(buttonbox.buttons().count(), 0); + QCOMPARE(buttonbox.buttons().size(), 0); } void tst_QDialogButtonBox::layoutReuse() @@ -130,7 +130,7 @@ void tst_QDialogButtonBox::testConstructor2() QDialogButtonBox buttonBox(orient); QCOMPARE(buttonBox.orientation(), orient); - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); } void tst_QDialogButtonBox::testConstructor3_data() @@ -167,7 +167,7 @@ void tst_QDialogButtonBox::testConstructor3() QDialogButtonBox buttonBox(buttons, (Qt::Orientation)orientation); QCOMPARE(int(buttonBox.orientation()), orientation); - QTEST(int(buttonBox.buttons().count()), "buttonCount"); + QTEST(int(buttonBox.buttons().size()), "buttonCount"); } void tst_QDialogButtonBox::testConstructor4_data() @@ -202,7 +202,7 @@ void tst_QDialogButtonBox::testConstructor4() QDialogButtonBox buttonBox(buttons); QCOMPARE(buttonBox.orientation(), Qt::Horizontal); - QTEST(int(buttonBox.buttons().count()), "buttonCount"); + QTEST(int(buttonBox.buttons().size()), "buttonCount"); } void tst_QDialogButtonBox::setOrientation_data() @@ -265,12 +265,12 @@ void tst_QDialogButtonBox::addButton1() { QFETCH(QDialogButtonBox::ButtonRole, role); QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QPushButton *button = new QPushButton(); buttonBox.addButton(button, role); - QTEST(int(buttonBox.buttons().count()), "totalCount"); + QTEST(int(buttonBox.buttons().size()), "totalCount"); QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>(); - QTEST(int(children.count()), "totalCount"); + QTEST(int(children.size()), "totalCount"); delete button; } @@ -293,11 +293,11 @@ void tst_QDialogButtonBox::addButton2() QFETCH(QString, text); QFETCH(QDialogButtonBox::ButtonRole, role); QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); buttonBox.addButton(text, role); - QTEST(int(buttonBox.buttons().count()), "totalCount"); + QTEST(int(buttonBox.buttons().size()), "totalCount"); QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>(); - QTEST(int(children.count()), "totalCount"); + QTEST(int(children.size()), "totalCount"); } void tst_QDialogButtonBox::addButton3_data() @@ -320,11 +320,11 @@ void tst_QDialogButtonBox::addButton3() { QFETCH(QDialogButtonBox::StandardButton, button); QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); buttonBox.addButton(button); - QTEST(int(buttonBox.buttons().count()), "totalCount"); + QTEST(int(buttonBox.buttons().size()), "totalCount"); QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>(); - QTEST(int(children.count()), "totalCount"); + QTEST(int(children.size()), "totalCount"); } void tst_QDialogButtonBox::clear_data() @@ -344,9 +344,9 @@ void tst_QDialogButtonBox::clear() for (int i = 1; i < rolesToAdd; ++i) buttonBox.addButton("Happy", QDialogButtonBox::ButtonRole(i)); buttonBox.clear(); - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>(); - QCOMPARE(children.count(), 0); + QCOMPARE(children.size(), 0); } void tst_QDialogButtonBox::removeButton_data() @@ -362,31 +362,31 @@ void tst_QDialogButtonBox::removeButton() QFETCH(QDialogButtonBox::ButtonRole, roleToAdd); QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QPushButton *button = new QPushButton("RemoveButton test"); buttonBox.addButton(button, roleToAdd); - QTEST(int(buttonBox.buttons().count()), "expectedCount"); + QTEST(int(buttonBox.buttons().size()), "expectedCount"); buttonBox.removeButton(button); - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); delete button; } void tst_QDialogButtonBox::testDelete() { QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QPushButton *deleteMe = new QPushButton("Happy"); buttonBox.addButton(deleteMe, QDialogButtonBox::HelpRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>(); - QCOMPARE(children.count(), 1); + QCOMPARE(children.size(), 1); delete deleteMe; children = buttonBox.findChildren<QAbstractButton *>(); - QCOMPARE(children.count(), 0); - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(children.size(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); } class ObjectDeleter : public QObject @@ -408,7 +408,7 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835() { { QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QSignalSpy buttonClickedSpy(&buttonBox, &QDialogButtonBox::clicked); QVERIFY(buttonClickedSpy.isValid()); @@ -417,21 +417,21 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835() QVERIFY(buttonBoxAcceptedSpy.isValid()); QPushButton *button = buttonBox.addButton("Test", QDialogButtonBox::AcceptRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); ObjectDeleter objectDeleter; connect(&buttonBox, &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteButton); button->click(); - QCOMPARE(buttonBox.buttons().count(), 0); - QCOMPARE(buttonClickedSpy.count(), 1); - QCOMPARE(buttonBoxAcceptedSpy.count(), 1); + QCOMPARE(buttonBox.buttons().size(), 0); + QCOMPARE(buttonClickedSpy.size(), 1); + QCOMPARE(buttonBoxAcceptedSpy.size(), 1); } { QPointer<QDialogButtonBox> buttonBox(new QDialogButtonBox); - QCOMPARE(buttonBox->buttons().count(), 0); + QCOMPARE(buttonBox->buttons().size(), 0); QSignalSpy buttonClickedSpy(buttonBox.data(), &QDialogButtonBox::clicked); QVERIFY(buttonClickedSpy.isValid()); @@ -440,7 +440,7 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835() QVERIFY(buttonBoxAcceptedSpy.isValid()); QPushButton *button = buttonBox->addButton("Test", QDialogButtonBox::AcceptRole); - QCOMPARE(buttonBox->buttons().count(), 1); + QCOMPARE(buttonBox->buttons().size(), 1); ObjectDeleter objectDeleter; connect(buttonBox.data(), &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteSender); @@ -448,8 +448,8 @@ void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835() button->click(); QVERIFY(buttonBox.isNull()); - QCOMPARE(buttonClickedSpy.count(), 1); - QCOMPARE(buttonBoxAcceptedSpy.count(), 0); + QCOMPARE(buttonClickedSpy.size(), 1); + QCOMPARE(buttonBoxAcceptedSpy.size(), 0); } } @@ -457,24 +457,24 @@ void tst_QDialogButtonBox::testMultipleAdd() { // Add a button into the thing multiple times. QDialogButtonBox buttonBox; - QCOMPARE(buttonBox.buttons().count(), 0); + QCOMPARE(buttonBox.buttons().size(), 0); QPushButton *button = new QPushButton("Foo away"); buttonBox.addButton(button, QDialogButtonBox::AcceptRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole); buttonBox.addButton(button, QDialogButtonBox::AcceptRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole); // Add it again with a different role buttonBox.addButton(button, QDialogButtonBox::RejectRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole); // Add it as an "invalid" role buttonBox.addButton(button, QDialogButtonBox::InvalidRole); - QCOMPARE(buttonBox.buttons().count(), 1); + QCOMPARE(buttonBox.buttons().size(), 1); QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole); } @@ -594,13 +594,13 @@ void tst_QDialogButtonBox::testSignals() if (clickMe) clickMe->click(); - QTRY_COMPARE(clicked2.count(), clicked2Count); - if (clicked2.count() > 0) + QTRY_COMPARE(clicked2.size(), clicked2Count); + if (clicked2.size() > 0) QCOMPARE(qvariant_cast<QAbstractButton *>(clicked2.at(0).at(0)), clickMe); - QTEST(int(accept.count()), "acceptCount"); - QTEST(int(reject.count()), "rejectCount"); - QTEST(int(helpRequested.count()), "helpRequestedCount"); + QTEST(int(accept.size()), "acceptCount"); + QTEST(int(reject.size()), "rejectCount"); + QTEST(int(helpRequested.size()), "helpRequestedCount"); } void tst_QDialogButtonBox::testSignalOrder() @@ -756,7 +756,7 @@ void tst_QDialogButtonBox::testRemove() button->click(); QTest::qWait(100); - QCOMPARE(clicked.count(), 0); + QCOMPARE(clicked.size(), 0); delete button; } @@ -818,7 +818,7 @@ void tst_QDialogButtonBox::task191642_default() QVERIFY(QTest::qWaitForWindowActive(&dlg)); QVERIFY(def->isDefault()); QTest::keyPress( &dlg, Qt::Key_Enter ); - QCOMPARE(clicked.count(), 1); + QCOMPARE(clicked.size(), 1); } void tst_QDialogButtonBox::testDeletedStandardButton() diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index eb60e5b408..d689260076 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -270,12 +270,12 @@ void tst_QDockWidget::features() QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*(static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData())), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); setFeature(&dw, QDockWidget::DockWidgetClosable); @@ -283,12 +283,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); setFeature(&dw, QDockWidget::DockWidgetMovable, false); @@ -296,12 +296,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); setFeature(&dw, QDockWidget::DockWidgetMovable); @@ -309,12 +309,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); setFeature(&dw, QDockWidget::DockWidgetFloatable, false); @@ -322,12 +322,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); setFeature(&dw, QDockWidget::DockWidgetFloatable); @@ -335,12 +335,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); // set all at once @@ -349,12 +349,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); dw.setFeatures(QDockWidget::DockWidgetClosable); @@ -362,12 +362,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); dw.setFeatures(allDockWidgetFeatures); @@ -375,12 +375,12 @@ void tst_QDockWidget::features() QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), (int)dw.features()); spy.clear(); dw.setFeatures(dw.features()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); } @@ -407,20 +407,20 @@ void tst_QDockWidget::setFloating() QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50); QVERIFY(dw.isFloating()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating()); spy.clear(); dw.setFloating(dw.isFloating()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); dw.setFloating(false); QVERIFY(!dw.isFloating()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating()); spy.clear(); dw.setFloating(dw.isFloating()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); } @@ -444,12 +444,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::RightDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::RightDockWidgetArea); @@ -457,12 +457,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::TopDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea); @@ -470,12 +470,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::BottomDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea); @@ -483,12 +483,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // multiple dock window areas dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); @@ -498,12 +498,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); //QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -512,12 +512,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); //QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea); @@ -526,12 +526,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); //QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); //dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::FloatingDockWidgetArea); dw.setAllowedAreas(Qt::BottomDockWidgetArea); @@ -541,12 +541,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); //QVERIFY(dw.isAreaAllowed(Qt::FloatingDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); @@ -555,12 +555,12 @@ void tst_QDockWidget::allowedAreas() QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); //QVERIFY(!dw.isAreaAllowed(Qt::FloatingDockWidgetArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), dw.allowedAreas()); spy.clear(); dw.setAllowedAreas(dw.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QDockWidget::toggleViewAction() @@ -588,65 +588,65 @@ void tst_QDockWidget::visibilityChanged() mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); mw.show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.hide(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw.hide(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw.show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.show(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QDockWidget dw2; mw.tabifyDockWidget(&dw, &dw2); dw2.show(); dw2.raise(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw2.hide(); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw2.show(); dw2.raise(); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw.raise(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.raise(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); dw2.raise(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw2.raise(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); } @@ -700,56 +700,56 @@ void tst_QDockWidget::dockLocationChanged() QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea))); mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::LeftDockWidgetArea); spy.clear(); mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::LeftDockWidgetArea); spy.clear(); mw.addDockWidget(Qt::RightDockWidgetArea, &dw); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::RightDockWidgetArea); spy.clear(); mw.removeDockWidget(&dw); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QDockWidget dw2; dw2.setObjectName("dock2"); mw.addDockWidget(Qt::TopDockWidgetArea, &dw2); mw.tabifyDockWidget(&dw2, &dw); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); mw.splitDockWidget(&dw2, &dw, Qt::Horizontal); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); dw.setFloating(true); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::NoDockWidgetArea); spy.clear(); dw.setFloating(false); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); QByteArray ba = mw.saveState(); mw.restoreState(ba); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); } @@ -1020,9 +1020,9 @@ void tst_QDockWidget::task258459_visibilityChanged() QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool))); win.show(); QVERIFY(QTest::qWaitForWindowActive(&win)); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible } @@ -1276,14 +1276,14 @@ bool tst_QDockWidget::checkFloatingTabs(QMainWindow* mainWindow, QPointer<QDockW // both dock widgets must be direct children of the main window const QList<QDockWidget*> children = ftabs->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly); - if (dwList.count() > 0) + if (dwList.size() > 0) { - if (dwList.count() != children.count()) { - qCDebug(lcTestDockWidget) << "Expected DockWidgetGroupWindow children:" << dwList.count() - << "Children found:" << children.count(); + if (dwList.size() != children.size()) { + qCDebug(lcTestDockWidget) << "Expected DockWidgetGroupWindow children:" << dwList.size() + << "Children found:" << children.size(); qCDebug(lcTestDockWidget) << "Expected:" << dwList; - qCDebug(lcTestDockWidget) << "Found in" << ftabs << ":" << children.count(); + qCDebug(lcTestDockWidget) << "Found in" << ftabs << ":" << children.size(); return false; } @@ -1580,7 +1580,7 @@ void tst_QDockWidget::dockPermissions() // both dock widgets must be direct children of the main window { const QList<QDockWidget*> children = mainWindow->findChildren<QDockWidget*>(QString(), Qt::FindDirectChildrenOnly); - QTRY_VERIFY(children.count() == 2); + QTRY_VERIFY(children.size() == 2); for (const QDockWidget* child : children) QTRY_VERIFY(child == d1 || child == d2); } diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 3d7eece17a..a380aef127 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -865,37 +865,37 @@ void tst_QDoubleSpinBox::editingFinished() QTest::keyClick(box, Qt::Key_Up); - QCOMPARE(editingFinishedSpy1.count(), 0); - QCOMPARE(editingFinishedSpy2.count(), 0); + QCOMPARE(editingFinishedSpy1.size(), 0); + QCOMPARE(editingFinishedSpy2.size(), 0); QTest::keyClick(box2, Qt::Key_Up); QTest::keyClick(box2, Qt::Key_Up); box2->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); box->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 1); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Up); - QCOMPARE(editingFinishedSpy1.count(), 1); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Enter); - QCOMPARE(editingFinishedSpy1.count(), 2); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 2); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Return); - QCOMPARE(editingFinishedSpy1.count(), 3); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 3); + QCOMPARE(editingFinishedSpy2.size(), 1); box2->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box2, Qt::Key_Enter); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 2); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 2); QTest::keyClick(box2, Qt::Key_Return); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 3); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 3); testFocusWidget.hide(); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 4); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 4); } void tst_QDoubleSpinBox::removeAll() @@ -1751,12 +1751,12 @@ void tst_QDoubleSpinBox::stepModifierPressAndHold() QStyle::CC_SpinBox, &spinBoxStyleOption, subControl, &spin); QTest::mousePress(&spin, Qt::LeftButton, modifiers, buttonRect.center()); - QTRY_VERIFY(spy.length() >= 3); + QTRY_VERIFY(spy.size() >= 3); QTest::mouseRelease(&spin, Qt::LeftButton, modifiers, buttonRect.center()); const auto value = spy.last().at(0); QVERIFY(value.userType() == QMetaType::Double); - QCOMPARE(value.toDouble(), spy.length() * expectedStepModifier); + QCOMPARE(value.toDouble(), spy.size() * expectedStepModifier); } QTEST_MAIN(tst_QDoubleSpinBox) diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp index 6a0749d7e3..149b6586ae 100644 --- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp @@ -77,7 +77,7 @@ void tst_QFontComboBox::currentFont_data() if (!QFontDatabase::isPrivateFamily(defaultFont.family())) QTest::newRow("default2") << defaultFont; QStringList list = QFontDatabase::families(); - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { QFont f = QFont(QStringList{QFontInfo(QFont(list.at(i))).family()}); if (!QFontDatabase::isPrivateFamily(f.families().first())) QTest::newRow(qPrintable(list.at(i))) << f; @@ -105,7 +105,7 @@ void tst_QFontComboBox::currentFont() if (oldCurrentFont != box.currentFont()) { //the signal may be emit twice if there is a foundry into brackets - QCOMPARE(spy0.count(),1); + QCOMPARE(spy0.size(),1); } } @@ -155,7 +155,7 @@ void tst_QFontComboBox::fontFilters() if((fontFilters & spacingMask) == spacingMask) fontFilters &= ~spacingMask; - for (int i = 0; i < list.count(); ++i) { + for (int i = 0; i < list.size(); ++i) { if (QFontDatabase::isPrivateFamily(list[i])) continue; if (fontFilters & QFontComboBox::ScalableFonts) { @@ -180,7 +180,7 @@ void tst_QFontComboBox::fontFilters() if (c == 0) QCOMPARE(box.currentFont(), QFont()); - QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0); + QCOMPARE(spy0.size(), (currentFont != box.currentFont()) ? 1 : 0); } // public QSize sizeHint() const @@ -221,17 +221,17 @@ void tst_QFontComboBox::writingSystem() QCOMPARE(box.writingSystem(), writingSystem); QStringList list = QFontDatabase::families(writingSystem); - int c = list.count(); - for (int i = 0; i < list.count(); ++i) { + int c = list.size(); + for (int i = 0; i < list.size(); ++i) { if (QFontDatabase::isPrivateFamily(list[i])) c--; } QCOMPARE(box.model()->rowCount(), c); - if (list.count() == 0) + if (list.size() == 0) QCOMPARE(box.currentFont(), QFont()); - QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0); + QCOMPARE(spy0.size(), (currentFont != box.currentFont()) ? 1 : 0); } // protected void currentFontChanged(QFont const& f) @@ -245,11 +245,11 @@ void tst_QFontComboBox::currentFontChanged() if (box->model()->rowCount() > 2) { QTest::keyPress(box, Qt::Key_Down); - QCOMPARE(spy0.count(), 1); + QCOMPARE(spy0.size(), 1); QFont f( "Sans Serif" ); box->setCurrentFont(f); - QCOMPARE(spy0.count(), 2); + QCOMPARE(spy0.size(), 2); } else qWarning("Not enough fonts installed on test system. Consider adding some"); } diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp index 6c42baf147..c5640d2571 100644 --- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp @@ -371,8 +371,8 @@ void tst_QGroupBox::clicked() else QTest::mouseClick(&testWidget, Qt::LeftButton); - QTEST(int(spy.count()), "clickedCount"); - if (spy.count() > 0) + QTEST(int(spy.size()), "clickedCount"); + if (spy.size() > 0) QTEST(spy.at(0).at(0).toBool(), "finalCheck"); QTEST(testWidget.isChecked(), "finalCheck"); } @@ -386,9 +386,9 @@ void tst_QGroupBox::toggledVsClicked() QSignalSpy clickSpy(&groupBox, SIGNAL(clicked(bool))); groupBox.setChecked(!groupBox.isChecked()); - QCOMPARE(clickSpy.count(), 0); - QCOMPARE(toggleSpy.count(), 1); - if (toggleSpy.count() > 0) + QCOMPARE(clickSpy.size(), 0); + QCOMPARE(toggleSpy.size(), 1); + if (toggleSpy.size() > 0) QCOMPARE(toggleSpy.at(0).at(0).toBool(), groupBox.isChecked()); connect(&groupBox, SIGNAL(clicked(bool)), this, SLOT(clickTimestampSlot())); @@ -401,8 +401,8 @@ void tst_QGroupBox::toggledVsClicked() QStyle::SC_GroupBoxCheckBox, &groupBox); QTest::mouseClick(&groupBox, Qt::LeftButton, {}, rect.center()); - QCOMPARE(clickSpy.count(), 1); - QCOMPARE(toggleSpy.count(), 2); + QCOMPARE(clickSpy.size(), 1); + QCOMPARE(toggleSpy.size(), 2); QVERIFY(toggleTimeStamp < clickTimeStamp); } @@ -598,9 +598,9 @@ void tst_QGroupBox::buttonPressKeys() const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme() ->themeHint(QPlatformTheme::ButtonPressKeys) .value<QList<Qt::Key>>(); - for (int i = 0; i < buttonPressKeys.length(); ++i) { + for (int i = 0; i < buttonPressKeys.size(); ++i) { QTest::keyClick(&groupBox, buttonPressKeys[i]); - QCOMPARE(clickedSpy.length(), i + 1); + QCOMPARE(clickedSpy.size(), i + 1); } } diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index b1928e3785..1dc398cefd 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -652,7 +652,7 @@ void tst_QLineEdit::setInputMask() testWidget->insert(input); } else { psKeyClick(testWidget, Qt::Key_Home); - for (int i=0; i<input.length(); i++) + for (int i=0; i<input.size(); i++) QTest::keyClick(testWidget, input.at(i).toLatin1()); } @@ -919,8 +919,8 @@ void tst_QLineEdit::hasAcceptableInputValidator() qApp->sendEvent(testWidget, &lostFocus); QVERIFY(testWidget->hasAcceptableInput()); - QCOMPARE(spyChanged.count(), 2); - QCOMPARE(spyEdited.count(), 0); + QCOMPARE(spyChanged.size(), 2); + QCOMPARE(spyEdited.size(), 0); } @@ -1592,7 +1592,7 @@ void tst_QLineEdit::setText() QSignalSpy editedSpy(testWidget, SIGNAL(textEdited(QString))); QSignalSpy changedSpy(testWidget, SIGNAL(textChanged(QString))); testWidget->setText("hello"); - QCOMPARE(editedSpy.count(), 0); + QCOMPARE(editedSpy.size(), 0); QCOMPARE(changedSpy.value(0).value(0).toString(), QString("hello")); } @@ -1664,7 +1664,7 @@ void tst_QLineEdit::displayText_data() QString input; QString pass; input = "Hello World"; - pass.resize(input.length()); + pass.resize(input.size()); pass.fill(passChar); QTest::newRow(QString(s + " text0").toLatin1()) << input << pass << m << bool(use_setText); QTest::newRow(QString(s + " text1").toLatin1()) << QString("") << @@ -1672,14 +1672,14 @@ void tst_QLineEdit::displayText_data() m << bool(use_setText); QTest::newRow(QString(s + " text2").toLatin1()) << QString("A") << QString(passChar) << m << bool(use_setText); input = QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry"); - pass.resize(input.length()); + pass.resize(input.size()); pass.fill(passChar); QTest::newRow(QString(s + " text3").toLatin1()) << input << pass << m << bool(use_setText); input = QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\""); - pass.fill(passChar, input.length()); + pass.fill(passChar, input.size()); QTest::newRow(QString(s + " text4").toLatin1()) << input << pass << m << bool(use_setText); input = QString("Hello") + QChar(0xa0) + "World"; - pass.resize(input.length()); + pass.resize(input.size()); pass.fill(passChar); QTest::newRow(QString(s + " text with nbsp").toLatin1()) << input << pass << m << bool(use_setText); } @@ -2292,7 +2292,7 @@ void tst_QLineEdit::deleteSelectedText() #ifndef QT_NO_CONTEXTMENU QMenu *menu = edit.createStandardContextMenu(); - for (int i = 0; i < menu->actions().count(); ++i) { + for (int i = 0; i < menu->actions().size(); ++i) { QAction *current = menu->actions().at(i); if (current->text() == QLineEdit::tr("Delete")) { current->trigger(); //this will delete the whole text selected @@ -2425,7 +2425,7 @@ class QIntFixValidator : public QIntValidator { public: QIntFixValidator(int min, int max, QObject *parent) : QIntValidator(min, max, parent) {} void fixup (QString &input) const override { - for (int i=0; i<input.length(); ++i) + for (int i=0; i<input.size(); ++i) if (!input.at(i).isNumber()) { input[(int)i] = QChar('0'); } @@ -2991,7 +2991,7 @@ void tst_QLineEdit::setSelection_data() QTest::newRow(selectionTestName(start, length).constData()) << text << start << length << pos << QString("Abc ") << true; - start = -1; length = 0; pos = text.length(); + start = -1; length = 0; pos = text.size(); QTest::newRow(selectionTestName(start, length).constData()) << text << start << length << pos << QString() << false; @@ -3011,7 +3011,7 @@ void tst_QLineEdit::setSelection_data() QTest::newRow(selectionTestName(start, length).constData()) << text << start << length << pos << QString("A") << true; - start = -1; length = -1; pos = text.length(); + start = -1; length = -1; pos = text.size(); QTest::newRow(selectionTestName(start, length).constData()) << text << start << length << pos << QString() << false; } @@ -3308,7 +3308,7 @@ void tst_QLineEdit::validateOnFocusOut() QTest::keyPress(testWidget, '0'); QCOMPARE(testWidget->text(), QString("10")); testWidget->clearFocus(); - QCOMPARE(editingFinishedSpy.count(), 0); + QCOMPARE(editingFinishedSpy.size(), 0); testWidget->setFocus(); centerOnScreen(testWidget); @@ -3321,7 +3321,7 @@ void tst_QLineEdit::validateOnFocusOut() QTRY_COMPARE(testWidget->text(), QString("100")); testWidget->clearFocus(); - QCOMPARE(editingFinishedSpy.count(), 1); + QCOMPARE(editingFinishedSpy.size(), 1); } void tst_QLineEdit::editInvalidText() @@ -3499,7 +3499,7 @@ void tst_QLineEdit::noTextEditedOnClear() testWidget->setText("Test"); QSignalSpy textEditedSpy(testWidget, SIGNAL(textEdited(QString))); testWidget->clear(); - QCOMPARE(textEditedSpy.count(), 0); + QCOMPARE(textEditedSpy.size(), 0); } void tst_QLineEdit::textMargin_data() @@ -3603,7 +3603,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag() // Focus drop with no edits shouldn't emit signal, edited flag == false testWidget.clearFocus(); // Signal not emitted QVERIFY(!testWidget.hasFocus()); - QCOMPARE(leSpy.count(), 0); + QCOMPARE(leSpy.size(), 0); // Focus drop after edits should emit signal, edited flag == true testWidget.setFocus(); @@ -3611,7 +3611,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag() QTest::keyClicks(&testWidget, "edit1 "); // edited flag set testWidget.clearFocus(); // edited flag cleared, signal emitted QVERIFY(!testWidget.hasFocus()); - QCOMPARE(leSpy.count(), 1); + QCOMPARE(leSpy.size(), 1); // Only text related keys should set edited flag testWidget.setFocus(); @@ -3621,7 +3621,7 @@ void tst_QLineEdit::returnKeyClearsEditedFlag() QTest::keyClick(&testWidget, Qt::Key_PageUp); testWidget.clearFocus(); // Signal not emitted QVERIFY(!testWidget.hasFocus()); - QCOMPARE(leSpy.count(), 1); // No change + QCOMPARE(leSpy.size(), 1); // No change // Return should always emit signal testWidget.setFocus(); @@ -3629,12 +3629,12 @@ void tst_QLineEdit::returnKeyClearsEditedFlag() QTest::keyClick(&testWidget, Qt::Key_Return); /* Without edits, signal emitted, edited flag cleared */ - QCOMPARE(leSpy.count(), 2); + QCOMPARE(leSpy.size(), 2); QTest::keyClicks(&testWidget, "edit2 "); // edited flag set QTest::keyClick(&testWidget, Qt::Key_Return); /* With edits, signal emitted, edited flag cleared */ - QCOMPARE(leSpy.count(), 3); + QCOMPARE(leSpy.size(), 3); /* After editing the line edit following a Return key press with a focus drop should not emit signal a second time since Return now @@ -3642,10 +3642,10 @@ void tst_QLineEdit::returnKeyClearsEditedFlag() QTest::keyClicks(&testWidget, "edit3 "); // edited flag set QTest::keyClick(&testWidget, Qt::Key_Return); /* signal emitted, edited flag cleared */ - QCOMPARE(leSpy.count(), 4); + QCOMPARE(leSpy.size(), 4); testWidget.clearFocus(); // Signal not emitted since edited == false QVERIFY(!testWidget.hasFocus()); - QCOMPARE(leSpy.count(), 4); // No change + QCOMPARE(leSpy.size(), 4); // No change } #ifndef QT_NO_CURSOR @@ -3721,19 +3721,19 @@ void tst_QLineEdit::task174640_editingFinished() le1->setFocus(); QTRY_VERIFY(le1->hasFocus()); - QCOMPARE(editingFinishedSpy.count(), 0); + QCOMPARE(editingFinishedSpy.size(), 0); le2->setFocus(); QTRY_VERIFY(le2->hasFocus()); // editingFinished will not be emitted anew because no editing happened - QCOMPARE(editingFinishedSpy.count(), 0); + QCOMPARE(editingFinishedSpy.size(), 0); le1->setFocus(); QTRY_VERIFY(le1->hasFocus()); QTest::keyPress(le1, Qt::Key_Plus); le2->setFocus(); QTRY_VERIFY(le2->hasFocus()); - QCOMPARE(editingFinishedSpy.count(), 1); + QCOMPARE(editingFinishedSpy.size(), 1); editingFinishedSpy.clear(); le1->setFocus(); @@ -3748,7 +3748,7 @@ void tst_QLineEdit::task174640_editingFinished() mw.activateWindow(); delete testMenu1; - QCOMPARE(editingFinishedSpy.count(), 0); + QCOMPARE(editingFinishedSpy.size(), 0); QTRY_VERIFY(le1->hasFocus()); // Ensure le1 has been edited QTest::keyPress(le1, Qt::Key_Plus); @@ -3761,7 +3761,7 @@ void tst_QLineEdit::task174640_editingFinished() QTest::qWait(20); mw.activateWindow(); delete testMenu2; - QCOMPARE(editingFinishedSpy.count(), 1); + QCOMPARE(editingFinishedSpy.size(), 1); } #if QT_CONFIG(completer) @@ -3846,7 +3846,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged() QTest::keyPress(&lineEdit, 'd'); QTest::keyPress(&lineEdit, 'e'); QTest::keyPress(&lineEdit, 'f'); - QCOMPARE(changedSpy.count(), 5); + QCOMPARE(changedSpy.size(), 5); } void tst_QLineEdit::task233101_cursorPosAfterInputMethod_data() @@ -4061,7 +4061,7 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() QTRY_VERIFY(le.hasFocus()); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() @@ -4348,14 +4348,14 @@ void tst_QLineEdit::inputMethodSelection() testWidget->setSelection(0,0); QSignalSpy selectionSpy(testWidget, SIGNAL(selectionChanged())); - QCOMPARE(selectionSpy.count(), 0); + QCOMPARE(selectionSpy.size(), 0); QCOMPARE(testWidget->selectionStart(), -1); QCOMPARE(testWidget->selectionEnd(), -1); QCOMPARE(testWidget->selectionLength(), 0); testWidget->setSelection(0,5); - QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(selectionSpy.size(), 1); QCOMPARE(testWidget->selectionStart(), 0); QCOMPARE(testWidget->selectionEnd(), 5); QCOMPARE(testWidget->selectionLength(), 5); @@ -4369,7 +4369,7 @@ void tst_QLineEdit::inputMethodSelection() QApplication::sendEvent(testWidget, &event); } - QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(selectionSpy.size(), 2); QCOMPARE(testWidget->selectionStart(), 12); QCOMPARE(testWidget->selectionEnd(), 17); QCOMPARE(testWidget->selectionLength(), 5); @@ -4382,7 +4382,7 @@ void tst_QLineEdit::inputMethodSelection() QApplication::sendEvent(testWidget, &event); } - QCOMPARE(selectionSpy.count(), 3); + QCOMPARE(selectionSpy.size(), 3); QCOMPARE(testWidget->selectionStart(), -1); QCOMPARE(testWidget->selectionEnd(), -1); QCOMPARE(testWidget->selectionLength(), 0); @@ -4570,11 +4570,11 @@ void tst_QLineEdit::clearButton() QSignalSpy spyEdited(filterLineEdit, &QLineEdit::textEdited); const QPoint clearButtonCenterPos = QRect(QPoint(0, 0), clearButton->size()).center(); QTest::mouseClick(clearButton, Qt::LeftButton, {}, clearButtonCenterPos); - QCOMPARE(spyEdited.count(), 1); + QCOMPARE(spyEdited.size(), 1); QTRY_COMPARE(clearButton->cursor().shape(), filterLineEdit->cursor().shape()); QTRY_COMPARE(filterModel->rowCount(), 3); QCoreApplication::processEvents(); - QCOMPARE(spyEdited.count(), 1); + QCOMPARE(spyEdited.size(), 1); filterLineEdit->setReadOnly(true); // QTBUG-34315 QVERIFY(!clearButton->isEnabled()); @@ -4851,7 +4851,7 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited() QSignalSpy spy(&lineEdit, SIGNAL(textEdited(QString))); lineEdit.setInputMask("AAAA"); lineEdit.setInputMask(QString()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } #if QT_CONFIG(shortcut) @@ -4912,7 +4912,7 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit() } const int activationCount = shouldBeHandledByQLineEdit ? 0 : 1; - QCOMPARE(spy.count(), activationCount); + QCOMPARE(spy.size(), activationCount); } #endif // QT_CONFIG(shortcut) @@ -4965,10 +4965,10 @@ void tst_QLineEdit::QTBUG_60319_setInputMaskCheckImSurroundingText() QLineEdit *testWidget = ensureTestWidget(); QString mask("+000(000)-000-00-00"); testWidget->setInputMask(mask); - testWidget->setCursorPosition(mask.length()); + testWidget->setCursorPosition(mask.size()); QString surroundingText = testWidget->inputMethodQuery(Qt::ImSurroundingText).toString(); int cursorPosition = testWidget->inputMethodQuery(Qt::ImCursorPosition).toInt(); - QCOMPARE(surroundingText.length(), cursorPosition); + QCOMPARE(surroundingText.size(), cursorPosition); } void tst_QLineEdit::testQuickSelectionWithMouse() @@ -5065,18 +5065,18 @@ void tst_QLineEdit::inputRejected() QSignalSpy spyInputRejected(testWidget, SIGNAL(inputRejected())); QTest::keyClicks(testWidget, "abcde"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); testWidget->setText("fghij"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); testWidget->insert("k"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); testWidget->clear(); testWidget->setMaxLength(5); QTest::keyClicks(testWidget, "abcde"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); QTest::keyClicks(testWidget, "fgh"); - QCOMPARE(spyInputRejected.count(), 3); + QCOMPARE(spyInputRejected.size(), 3); #if QT_CONFIG(clipboard) testWidget->clear(); spyInputRejected.clear(); @@ -5084,7 +5084,7 @@ void tst_QLineEdit::inputRejected() testWidget->paste(); // The first 5 characters are accepted, but // the last 2 are not. - QCOMPARE(spyInputRejected.count(), 1); + QCOMPARE(spyInputRejected.size(), 1); #endif testWidget->setMaxLength(INT_MAX); @@ -5093,15 +5093,15 @@ void tst_QLineEdit::inputRejected() QIntValidator intValidator(1, 100); testWidget->setValidator(&intValidator); QTest::keyClicks(testWidget, "11"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); QTest::keyClicks(testWidget, "a#"); - QCOMPARE(spyInputRejected.count(), 2); + QCOMPARE(spyInputRejected.size(), 2); #if QT_CONFIG(clipboard) testWidget->clear(); spyInputRejected.clear(); QApplication::clipboard()->setText("a#"); testWidget->paste(); - QCOMPARE(spyInputRejected.count(), 1); + QCOMPARE(spyInputRejected.size(), 1); #endif testWidget->clear(); @@ -5109,9 +5109,9 @@ void tst_QLineEdit::inputRejected() spyInputRejected.clear(); testWidget->setInputMask("999.999.999.999;_"); QTest::keyClicks(testWidget, "11"); - QCOMPARE(spyInputRejected.count(), 0); + QCOMPARE(spyInputRejected.size(), 0); QTest::keyClicks(testWidget, "a#"); - QCOMPARE(spyInputRejected.count(), 2); + QCOMPARE(spyInputRejected.size(), 2); } QTEST_MAIN(tst_QLineEdit) diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 6996591946..91aa651bab 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -2124,14 +2124,14 @@ void tst_QMainWindow::resizeDocks() int totalFromList = 0; int actualTotal = 0; - for (int i = 0; i < docks.count(); ++i) { + for (int i = 0; i < docks.size(); ++i) { totalFromList += sizes[i]; QSize s = list[i]->size(); actualTotal += (orientation == Qt::Horizontal) ? s.width() : s.height(); // qDebug() << list[i] << list[i]->size() << sizes[i]; } - for (int i = 0; i < docks.count(); ++i) { + for (int i = 0; i < docks.size(); ++i) { QSize s = list[i]->size(); int value = (orientation == Qt::Horizontal) ? s.width() : s.height(); QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList))); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 1d76bb4d72..9cdbbc5b0f 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -138,7 +138,7 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const case Tiled: { // Calculate the number of rows and columns. - const int n = subWindows.count(); + const int n = subWindows.size(); const int numColumns = qMax(qCeil(qSqrt(qreal(n))), 1); const int numRows = qMax((n % numColumns) ? (n / numColumns + 1) : (n / numColumns), 1); @@ -317,12 +317,12 @@ void tst_QMdiArea::subWindowActivated() widget->show(); qApp->processEvents(); QVERIFY( activeWindow == workspace->activeSubWindow() ); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } QList<QMdiSubWindow *> windows = workspace->subWindowList(); - QCOMPARE( (int)windows.count(), count ); + QCOMPARE( (int)windows.size(), count ); for ( i = 0; i < count; ++i ) { QMdiSubWindow *window = windows.at(i); @@ -346,13 +346,13 @@ void tst_QMdiArea::subWindowActivated() workspace->activeSubWindow()->close(); qApp->processEvents(); QCOMPARE(activeWindow, workspace->activeSubWindow()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } QVERIFY(!activeWindow); QVERIFY(!workspace->activeSubWindow()); - QCOMPARE(workspace->subWindowList().count(), 0); + QCOMPARE(workspace->subWindowList().size(), 0); { workspace->hide(); @@ -360,14 +360,14 @@ void tst_QMdiArea::subWindowActivated() widget->setAttribute(Qt::WA_DeleteOnClose); QMdiSubWindow *window = workspace->addSubWindow(widget); widget->show(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); workspace->show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY( activeWindow == window ); window->close(); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY( activeWindow == 0 ); } @@ -379,15 +379,15 @@ void tst_QMdiArea::subWindowActivated() QMdiSubWindow *window = workspace->addSubWindow(widget); widget->showMaximized(); qApp->sendPostedEvents(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); workspace->show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY( activeWindow == window ); window->close(); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY( activeWindow == 0 ); } @@ -397,13 +397,13 @@ void tst_QMdiArea::subWindowActivated() widget->setAttribute(Qt::WA_DeleteOnClose); QMdiSubWindow *window = workspace->addSubWindow(widget); widget->showMinimized(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY( activeWindow == window ); QCOMPARE(workspace->activeSubWindow(), window); window->close(); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QVERIFY(!workspace->activeSubWindow()); QVERIFY(!activeWindow); @@ -431,12 +431,12 @@ void tst_QMdiArea::subWindowActivated2() QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*))); for (int i = 0; i < 5; ++i) mdiArea.addSubWindow(new QWidget); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); mdiArea.show(); mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); - QTRY_COMPARE(spy.count(), 5); + QTRY_COMPARE(spy.size(), 5); QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back()); spy.clear(); @@ -445,13 +445,13 @@ void tst_QMdiArea::subWindowActivated2() QMdiSubWindow *staysOnTopWindow = mdiArea.subWindowList().at(3); staysOnTopWindow->setWindowFlags(Qt::WindowStaysOnTopHint); mdiArea.setActiveSubWindow(staysOnTopWindow); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(mdiArea.activeSubWindow(), staysOnTopWindow); spy.clear(); QMdiSubWindow *activeSubWindow = mdiArea.subWindowList().at(2); mdiArea.setActiveSubWindow(activeSubWindow); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); @@ -459,7 +459,7 @@ void tst_QMdiArea::subWindowActivated2() // is unchanged after hide/show. mdiArea.hide(); QTest::qWait(100); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -487,7 +487,7 @@ void tst_QMdiArea::subWindowActivated2() #endif if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive)) QSKIP("QTBUG-25298: Unstable on some X11 window managers"); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -497,7 +497,7 @@ void tst_QMdiArea::subWindowActivated2() mdiArea.showNormal(); mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); } @@ -534,7 +534,7 @@ void tst_QMdiArea::subWindowActivatedWithMinimize() QVERIFY(!workspace->activeSubWindow()); QVERIFY(!activeWindow); - QVERIFY( workspace->subWindowList().count() == 0 ); + QVERIFY( workspace->subWindowList().size() == 0 ); } void tst_QMdiArea::showWindows() @@ -813,14 +813,14 @@ void tst_QMdiArea::fixedSize() } QList<QMdiSubWindow *> windows = ws->subWindowList(); - for (i = 0; i < (int)windows.count(); ++i) { + for (i = 0; i < (int)windows.size(); ++i) { QMdiSubWindow *child = windows.at(i); QCOMPARE(child->size(), fixed); } ws->cascadeSubWindows(); ws->resize(800, 800); - for (i = 0; i < (int)windows.count(); ++i) { + for (i = 0; i < (int)windows.size(); ++i) { QMdiSubWindow *child = windows.at(i); QCOMPARE(child->size(), fixed); } @@ -828,13 +828,13 @@ void tst_QMdiArea::fixedSize() ws->tileSubWindows(); ws->resize(800, 800); - for (i = 0; i < (int)windows.count(); ++i) { + for (i = 0; i < (int)windows.size(); ++i) { QMdiSubWindow *child = windows.at(i); QCOMPARE(child->size(), fixed); } ws->resize(500, 500); - for (i = 0; i < (int)windows.count(); ++i) { + for (i = 0; i < (int)windows.size(); ++i) { QMdiSubWindow *child = windows.at(i); delete child; } @@ -913,7 +913,7 @@ void tst_QMdiArea::setActiveSubWindow() QVERIFY(windows[i]->isHidden()); workspace.setActiveSubWindow(windows[i]); } - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QVERIFY(!activeWindow); spy.clear(); @@ -923,7 +923,7 @@ void tst_QMdiArea::setActiveSubWindow() QVERIFY(!windows[i]->isHidden()); workspace.setActiveSubWindow(windows[i]); qApp->processEvents(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(activeWindow, windows[i]); spy.clear(); } @@ -931,7 +931,7 @@ void tst_QMdiArea::setActiveSubWindow() // Deactivate active window QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]); workspace.setActiveSubWindow(0); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QVERIFY(!activeWindow); QVERIFY(!workspace.activeSubWindow()); @@ -1076,11 +1076,11 @@ void tst_QMdiArea::addAndRemoveWindows() QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); { // addSubWindow with large widget - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); QWidget *window = workspace.addSubWindow(new LargeWidget); QVERIFY(window); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), workspace.viewport()->size()); } @@ -1091,7 +1091,7 @@ void tst_QMdiArea::addAndRemoveWindows() workspace.addSubWindow(window); QVERIFY(window); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 2); + QCOMPARE(workspace.subWindowList().size(), 2); QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), window->minimumSize()); } @@ -1103,7 +1103,7 @@ void tst_QMdiArea::addAndRemoveWindows() workspace.addSubWindow(window); QVERIFY(window); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 3); + QCOMPARE(workspace.subWindowList().size(), 3); QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), QSize(1500, 1500)); } @@ -1112,7 +1112,7 @@ void tst_QMdiArea::addAndRemoveWindows() QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget"); QWidget *window = workspace.addSubWindow(0); QVERIFY(!window); - QCOMPARE(workspace.subWindowList().count(), 3); + QCOMPARE(workspace.subWindowList().size(), 3); } { // addChildWindow @@ -1121,7 +1121,7 @@ void tst_QMdiArea::addAndRemoveWindows() qApp->processEvents(); QCOMPARE(window->windowFlags(), DefaultWindowFlags); window->setWidget(new QWidget); - QCOMPARE(workspace.subWindowList().count(), 4); + QCOMPARE(workspace.subWindowList().size(), 4); QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added"); workspace.addSubWindow(window); } @@ -1129,7 +1129,7 @@ void tst_QMdiArea::addAndRemoveWindows() { // addChildWindow with 0 pointer QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget"); workspace.addSubWindow(0); - QCOMPARE(workspace.subWindowList().count(), 4); + QCOMPARE(workspace.subWindowList().size(), 4); } // removeSubWindow @@ -1137,7 +1137,7 @@ void tst_QMdiArea::addAndRemoveWindows() workspace.removeSubWindow(window); delete window; } - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); // removeSubWindow with 0 pointer QTest::ignoreMessage(QtWarningMsg, "QMdiArea::removeSubWindow: null pointer to widget"); @@ -1145,7 +1145,7 @@ void tst_QMdiArea::addAndRemoveWindows() workspace.addSubWindow(new QPushButton(QLatin1String("Dummy to make workspace non-empty"))); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); // removeSubWindow with window not inside workspace QTest::ignoreMessage(QtWarningMsg,"QMdiArea::removeSubWindow: window is not inside workspace"); @@ -1187,20 +1187,20 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting() // 0 because the window list contains widgets and not actual // windows. Silly, but that's the behavior. - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); window.setWidget(new QWidget); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); window.setParent(0); // Will also reset window flags - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); window.setParent(&workspace); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); QCOMPARE(window.windowFlags(), DefaultWindowFlags); QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added"); workspace.addSubWindow(&window); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); } class MySubWindow : public QMdiSubWindow @@ -1257,17 +1257,17 @@ void tst_QMdiArea::closeWindows() QWidget *widget = new QWidget; QMdiSubWindow *subWindow = workspace.addSubWindow(widget); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); subWindow->close(); - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); // Close window QWidget *window = workspace.addSubWindow(new QWidget); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 1); + QCOMPARE(workspace.subWindowList().size(), 1); window->close(); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); const int windowCount = 10; @@ -1275,7 +1275,7 @@ void tst_QMdiArea::closeWindows() for (int i = 0; i < windowCount; ++i) workspace.addSubWindow(new QWidget)->show(); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), windowCount); + QCOMPARE(workspace.subWindowList().size(), windowCount); int activeSubWindowCount = 0; while (workspace.activeSubWindow()) { workspace.activeSubWindow()->close(); @@ -1283,19 +1283,19 @@ void tst_QMdiArea::closeWindows() ++activeSubWindowCount; } QCOMPARE(activeSubWindowCount, windowCount); - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); // Close all windows for (int i = 0; i < windowCount; ++i) workspace.addSubWindow(new QWidget)->show(); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), windowCount); + QCOMPARE(workspace.subWindowList().size(), windowCount); QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*))); workspace.closeAllSubWindows(); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 0); - QCOMPARE(spy.count(), 1); + QCOMPARE(workspace.subWindowList().size(), 0); + QCOMPARE(spy.size(), 1); QVERIFY(!activeWindow); } @@ -1321,7 +1321,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow() workspace.activateNextSubWindow(); qApp->processEvents(); QCOMPARE(workspace.activeSubWindow(), windows[i]); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } QVERIFY(activeWindow); @@ -1333,7 +1333,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow() workspace.activatePreviousSubWindow(); qApp->processEvents(); QCOMPARE(workspace.activeSubWindow(), windows[i]); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); if (i % 2 == 0) windows[i]->hide(); // 10, 8, 6, 4, 2, 0 @@ -1345,7 +1345,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow() // activateNextSubWindow with every 2nd window hidden for (int i = 0; i < windowCount / 2; ++i) { workspace.activateNextSubWindow(); // 1, 3, 5, 7, 9 - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]); @@ -1353,7 +1353,7 @@ void tst_QMdiArea::activateNextAndPreviousWindow() // activatePreviousSubWindow with every 2nd window hidden for (int i = 0; i < windowCount / 2; ++i) { workspace.activatePreviousSubWindow(); // 7, 5, 3, 1, 9 - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); } QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]); @@ -1400,8 +1400,8 @@ void tst_QMdiArea::subWindowList() { QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder); - QCOMPARE(widgets.count(), windowCount); - for (int i = 0; i < widgets.count(); ++i) + QCOMPARE(widgets.size(), windowCount); + for (int i = 0; i < widgets.size(); ++i) QCOMPARE(widgets.at(i), windows[i]); } @@ -1420,9 +1420,9 @@ void tst_QMdiArea::subWindowList() } if (windowOrder == QMdiArea::StackingOrder) { - QCOMPARE(subWindows.at(subWindows.count() - 1), windows[staysOnTop1]); - QCOMPARE(subWindows.at(subWindows.count() - 2), windows[activeSubWindow]); - QCOMPARE(subWindows.count(), windowCount); + QCOMPARE(subWindows.at(subWindows.size() - 1), windows[staysOnTop1]); + QCOMPARE(subWindows.at(subWindows.size() - 2), windows[activeSubWindow]); + QCOMPARE(subWindows.size(), windowCount); } else { // ActivationHistoryOrder QCOMPARE(subWindows, activationOrder); } @@ -1437,11 +1437,11 @@ void tst_QMdiArea::subWindowList() activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1); QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder); - QCOMPARE(widgets.count(), windowCount); + QCOMPARE(widgets.size(), windowCount); if (windowOrder == QMdiArea::StackingOrder) { - QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]); - QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]); - QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]); + QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop2]); + QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]); + QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]); } else { // ActivationHistory QCOMPARE(widgets, activationOrder); } @@ -1451,8 +1451,8 @@ void tst_QMdiArea::subWindowList() widgets = workspace.subWindowList(windowOrder); if (windowOrder == QMdiArea::StackingOrder) { - QCOMPARE(widgets.at(widgets.count() - 1), windows[activeSubWindow]); - QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]); + QCOMPARE(widgets.at(widgets.size() - 1), windows[activeSubWindow]); + QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]); QCOMPARE(widgets.at(0), windows[staysOnTop2]); } else { // ActivationHistoryOrder QCOMPARE(widgets, activationOrder); @@ -1463,9 +1463,9 @@ void tst_QMdiArea::subWindowList() widgets = workspace.subWindowList(windowOrder); if (windowOrder == QMdiArea::StackingOrder) { - QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]); - QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]); - QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]); + QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop2]); + QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop1]); + QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]); } else { // ActivationHistoryOrder QCOMPARE(widgets, activationOrder); } @@ -1475,9 +1475,9 @@ void tst_QMdiArea::subWindowList() widgets = workspace.subWindowList(windowOrder); if (windowOrder == QMdiArea::StackingOrder) { - QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop1]); - QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop2]); - QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]); + QCOMPARE(widgets.at(widgets.size() - 1), windows[staysOnTop1]); + QCOMPARE(widgets.at(widgets.size() - 2), windows[staysOnTop2]); + QCOMPARE(widgets.at(widgets.size() - 3), windows[activeSubWindow]); } else { // ActivationHistoryOrder QCOMPARE(widgets, activationOrder); } @@ -1518,14 +1518,14 @@ void tst_QMdiArea::setViewport() qApp->processEvents(); QList<QMdiSubWindow *> windowsBeforeViewportChange = workspace.subWindowList(); - QCOMPARE(windowsBeforeViewportChange.count(), windowCount); + QCOMPARE(windowsBeforeViewportChange.size(), windowCount); workspace.setViewport(new QWidget); qApp->processEvents(); QVERIFY(workspace.viewport() != firstViewport); QList<QMdiSubWindow *> windowsAfterViewportChange = workspace.subWindowList(); - QCOMPARE(windowsAfterViewportChange.count(), windowCount); + QCOMPARE(windowsAfterViewportChange.size(), windowCount); QCOMPARE(windowsAfterViewportChange, windowsBeforeViewportChange); // for (int i = 0; i < windowCount; ++i) { @@ -1541,7 +1541,7 @@ void tst_QMdiArea::setViewport() delete workspace.viewport(); qApp->processEvents(); - QCOMPARE(workspace.subWindowList().count(), 0); + QCOMPARE(workspace.subWindowList().size(), 0); QVERIFY(!workspace.activeSubWindow()); } @@ -1781,7 +1781,7 @@ void tst_QMdiArea::cascadeAndTileSubWindows() #endif QCOMPARE(windows.at(2)->geometry().top() - windows.at(1)->geometry().top(), dy); - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < windows.size(); ++i) { QMdiSubWindow *window = windows.at(i); if (i % 3 == 0) { QVERIFY(window->isMinimized()); @@ -1892,7 +1892,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() // Verify that activated windows still are maximized on activation. QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList(); - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { mdiArea.activateNextSubWindow(); QMdiSubWindow *window = subWindows.at(i); QCOMPARE(mdiArea.activeSubWindow(), window); @@ -1903,7 +1903,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() // Restore active window and verify that other windows aren't // maximized on activation. mdiArea.activeSubWindow()->showNormal(); - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { mdiArea.activateNextSubWindow(); QMdiSubWindow *window = subWindows.at(i); QCOMPARE(mdiArea.activeSubWindow(), window); @@ -1917,7 +1917,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() int indexOfMaximized = subWindows.indexOf(mdiArea.activeSubWindow()); // Verify that windows are not maximized on activation. - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { mdiArea.activateNextSubWindow(); QMdiSubWindow *window = subWindows.at(i); QCOMPARE(mdiArea.activeSubWindow(), window); @@ -1939,7 +1939,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() mdiArea.activeSubWindow()->showMaximized(); // Verify that minimized windows are maximized on activation. - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { mdiArea.activateNextSubWindow(); QMdiSubWindow *window = subWindows.at(i); QCOMPARE(mdiArea.activeSubWindow(), window); @@ -1949,7 +1949,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() // Verify that activated windows are maximized after closing // the active window - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { QVERIFY(mdiArea.activeSubWindow()); QVERIFY(mdiArea.activeSubWindow()->isMaximized()); mdiArea.activeSubWindow()->close(); @@ -2201,7 +2201,7 @@ void tst_QMdiArea::setActivationOrder() mdiArea.show(); QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); - for (int i = 0; i < subWindows.count(); ++i) { + for (int i = 0; i < subWindows.size(); ++i) { mdiArea.activateNextSubWindow(); QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(i)); qApp->processEvents(); @@ -2265,7 +2265,7 @@ void tst_QMdiArea::tabBetweenSubWindows() QCOMPARE(qApp->focusWidget(), focusWidget); QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*))); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Walk through the entire list of sub windows. #ifdef Q_OS_MAC @@ -2273,7 +2273,7 @@ void tst_QMdiArea::tabBetweenSubWindows() #endif QVERIFY(tabBetweenSubWindowsIn(&mdiArea)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.back()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); mdiArea.setActiveSubWindow(subWindows.front()); QCOMPARE(mdiArea.activeSubWindow(), subWindows.front()); @@ -2282,12 +2282,12 @@ void tst_QMdiArea::tabBetweenSubWindows() // Walk through the entire list of sub windows in the opposite direction (Ctrl-Shift-Tab). QVERIFY(tabBetweenSubWindowsIn(&mdiArea, -1, true)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.front()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Ctrl-Tab-Tab-Tab QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 3)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); mdiArea.setActiveSubWindow(subWindows.at(1)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(1)); @@ -2296,7 +2296,7 @@ void tst_QMdiArea::tabBetweenSubWindows() // Quick switch (Ctrl-Tab once) -> switch back to the previously active sub-window. QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 1)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QMdiArea::setViewMode() @@ -2330,7 +2330,7 @@ void tst_QMdiArea::setViewMode() QVERIFY(tabBar); QVERIFY(tabBar->isVisible()); - QCOMPARE(tabBar->count(), subWindows.count()); + QCOMPARE(tabBar->count(), subWindows.size()); QVERIFY(activeSubWindow->isMaximized()); QCOMPARE(tabBar->currentIndex(), subWindows.indexOf(activeSubWindow)); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 1bdb1e8201..561d082aff 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -528,9 +528,9 @@ void tst_QMdiSubWindow::emittingOfSignals() int count = 0; if (signal == SIGNAL(aboutToActivate())) { - count += spy.count(); + count += spy.size(); } else { - for (int i = 0; i < spy.count(); ++i) { + for (int i = 0; i < spy.size(); ++i) { Qt::WindowStates oldState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(0)); Qt::WindowStates newState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(1)); if (watchedState != Qt::WindowNoState) { @@ -553,7 +553,7 @@ void tst_QMdiSubWindow::emittingOfSignals() spy.clear(); triggerSignal(window, &workspace, signal); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); delete window; window = nullptr; @@ -1030,7 +1030,7 @@ void tst_QMdiSubWindow::setSystemMenu() subWindow->setSystemMenu(systemMenu); QCOMPARE(subWindow->systemMenu(), qobject_cast<QMenu *>(systemMenu)); QCOMPARE(subWindow->systemMenu()->parentWidget(), static_cast<QWidget *>(subWindow)); - QCOMPARE(subWindow->systemMenu()->actions().count(), 1); + QCOMPARE(subWindow->systemMenu()->actions().size(), 1); // Show the new system menu QVERIFY(!QApplication::activePopupWidget()); @@ -1254,7 +1254,7 @@ void tst_QMdiSubWindow::changeFocusWithTab() mdiArea.setWindowTitle(QLatin1String(QTest::currentTestFunction())); mdiArea.addSubWindow(widget); mdiArea.show(); - QCOMPARE(mdiArea.subWindowList().count(), 1); + QCOMPARE(mdiArea.subWindowList().size(), 1); QApplication::setActiveWindow(&mdiArea); QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(firstLineEdit)); @@ -1336,7 +1336,7 @@ void tst_QMdiSubWindow::closeEvent() QVERIFY(window->close()); QCOMPARE(closeSpy.count(), 3); - QCOMPARE(mdiArea.subWindowList().count(), 0); + QCOMPARE(mdiArea.subWindowList().size(), 0); } // There exists more tests in QMdiArea which covers window title support @@ -2101,7 +2101,7 @@ void tst_QMdiSubWindow::styleChange() // subWindowActivated should NOT be activated by a style change, // even if internally QMdiSubWindow un-minimizes subwindows temporarily. - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QMdiSubWindow::testFullScreenState() diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 602795debb..31a3addd44 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -257,11 +257,11 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) void tst_QMenu::addActionsAndClear() { - QCOMPARE(menus[0]->actions().count(), 0); + QCOMPARE(menus[0]->actions().size(), 0); createActions(); - QCOMPARE(menus[0]->actions().count(), 8); + QCOMPARE(menus[0]->actions().size(), 8); menus[0]->clear(); - QCOMPARE(menus[0]->actions().count(), 0); + QCOMPARE(menus[0]->actions().size(), 0); } static void testFunction0() {} @@ -1262,7 +1262,7 @@ void tst_QMenu::click_while_dismissing_submenu() //the submenu must have been hidden for the bug to be triggered QVERIFY(!sub.isVisible()); QTest::mouseRelease(menuWindow, Qt::LeftButton, {}, menu.rect().center() - QPoint(0, 2), 300); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #endif @@ -1838,12 +1838,12 @@ void tst_QMenu::menuSize_Scrolling() private: void showEvent(QShowEvent *e) override { - QVERIFY(actions().length() == m_numItems); + QVERIFY(actions().size() == m_numItems); int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, this); int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this); const QMargins cm = contentsMargins(); - QRect lastItem = actionGeometry(actions().at(actions().length() - 1)); + QRect lastItem = actionGeometry(actions().at(actions().size() - 1)); QSize s = size(); if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { @@ -1909,7 +1909,7 @@ void tst_QMenu::menuSize_Scrolling() QVERIFY(QTest::qWaitForWindowExposed(&menu)); QList<QAction *> actions = menu.actions(); - QCOMPARE(actions.length(), numItems); + QCOMPARE(actions.size(), numItems); MenuMetrics mm(&menu); QTest::keyClick(&menu, Qt::Key_Home); @@ -1989,11 +1989,11 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts() QSignalSpy actionKamenSpy(actionKamen, &QAction::triggered); QTest::keyClick(&widget, Qt::Key_K); - QTRY_COMPARE(actionKamenSpy.count(), 1); + QTRY_COMPARE(actionKamenSpy.size(), 1); QSignalSpy actionJoeSpy(actionJoe, &QAction::triggered); QTest::keyClick(&widget, Qt::Key_J, Qt::ControlModifier); - QTRY_COMPARE(actionJoeSpy.count(), 1); + QTRY_COMPARE(actionJoeSpy.size(), 1); } void tst_QMenu::screenOrientationChangedCloseMenu() diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 18aacc52c3..d6089cb1e4 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -1268,9 +1268,9 @@ void tst_QMenuBar::task223138_triggered() //let's trigger the first action top->trigger(); - QCOMPARE(menubarSpy.count(), 1); - QCOMPARE(menuSpy.count(), 1); - QCOMPARE(submenuSpy.count(), 0); + QCOMPARE(menubarSpy.size(), 1); + QCOMPARE(menuSpy.size(), 1); + QCOMPARE(submenuSpy.size(), 0); menubarSpy.clear(); menuSpy.clear(); @@ -1278,9 +1278,9 @@ void tst_QMenuBar::task223138_triggered() //let's trigger the sub action action->trigger(); - QCOMPARE(menubarSpy.count(), 1); - QCOMPARE(menuSpy.count(), 1); - QCOMPARE(submenuSpy.count(), 1); + QCOMPARE(menubarSpy.size(), 1); + QCOMPARE(menuSpy.size(), 1); + QCOMPARE(submenuSpy.size(), 1); } void tst_QMenuBar::task256322_highlight() @@ -1623,7 +1623,7 @@ void tst_QMenuBar::QTBUG_65488_hiddenActionTriggered() // click center of the blank area on the menubar where Action1 resided QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, win.menuBar()->geometry().center()); QCoreApplication::sendPostedEvents(); // make sure all queued events also dispatched - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } // QTBUG-56526 @@ -1697,13 +1697,13 @@ void tst_QMenuBar::QTBUG_25669_menubarActionDoubleTriggered() QPoint posAct2 = menuBarActionWindowPos(win.menuBar(), act2); QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct1); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.size(), 2); QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2); - QTRY_COMPARE(spy.count(), 3); + QTRY_COMPARE(spy.size(), 3); } void tst_QMenuBar::slotForTaskQTBUG53205() diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index bc3e0b1a8f..c44dab255d 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -70,7 +70,7 @@ void tst_QOpenGLWidget::create() QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped())); w->show(); QVERIFY(QTest::qWaitForWindowExposed(w.data())); - QVERIFY(frameSwappedSpy.count() > 0); + QVERIFY(frameSwappedSpy.size() > 0); QVERIFY(w->isValid()); QVERIFY(w->context()); @@ -165,7 +165,7 @@ void tst_QOpenGLWidget::createNonTopLevel() w.resize(400, 400); w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); - QVERIFY(frameSwappedSpy.count() > 0); + QVERIFY(frameSwappedSpy.size() > 0); QVERIFY(glw->m_resizeCalled); glw->m_resizeCalled = false; @@ -326,7 +326,7 @@ void tst_QOpenGLWidget::reparentTopLevel() { QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped); tabWidget.setCurrentIndex(tabWidget.addTab(glw1, "OpenGL widget 1")); - QTRY_VERIFY(frameSwappedSpy.count() > 0); + QTRY_VERIFY(frameSwappedSpy.size() > 0); } PainterWidget *glw2 = new PainterWidget; @@ -334,7 +334,7 @@ void tst_QOpenGLWidget::reparentTopLevel() { QSignalSpy frameSwappedSpy(glw2, &QOpenGLWidget::frameSwapped); tabWidget.setCurrentIndex(tabWidget.addTab(glw2, "OpenGL widget 2")); - QTRY_VERIFY(frameSwappedSpy.count() > 0); + QTRY_VERIFY(frameSwappedSpy.size() > 0); } QImage image = glw2->grabFramebuffer(); @@ -344,7 +344,7 @@ void tst_QOpenGLWidget::reparentTopLevel() { QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped); delete glw2; - QTRY_VERIFY(frameSwappedSpy.count() > 0); + QTRY_VERIFY(frameSwappedSpy.size() > 0); } image = glw1->grabFramebuffer(); @@ -356,7 +356,7 @@ void tst_QOpenGLWidget::reparentTopLevel() glw1->setParent(nullptr); glw1->show(); QVERIFY(QTest::qWaitForWindowExposed(glw1)); - QTRY_VERIFY(frameSwappedSpy.count() > 0); + QTRY_VERIFY(frameSwappedSpy.size() > 0); } image = glw1->grabFramebuffer(); @@ -366,7 +366,7 @@ void tst_QOpenGLWidget::reparentTopLevel() { QSignalSpy frameSwappedSpy(glw1, &QOpenGLWidget::frameSwapped); tabWidget.setCurrentIndex(tabWidget.addTab(glw1, "Re-added OpenGL widget 1")); - QTRY_VERIFY(frameSwappedSpy.count() > 0); + QTRY_VERIFY(frameSwappedSpy.size() > 0); } image = glw1->grabFramebuffer(); diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index e0c213f8e0..e3ccc58867 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -393,7 +393,7 @@ void tst_QPlainTextEdit::cursorPositionChanged() spy.clear(); QTest::keyClick(ed, Qt::Key_A); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTextCursor cursor = ed->textCursor(); cursor.movePosition(QTextCursor::Start); @@ -401,23 +401,23 @@ void tst_QPlainTextEdit::cursorPositionChanged() cursor.movePosition(QTextCursor::End); spy.clear(); cursor.insertText("Test"); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); cursor.movePosition(QTextCursor::End); ed->setTextCursor(cursor); cursor.movePosition(QTextCursor::Start); spy.clear(); cursor.insertText("Test"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QTest::keyClick(ed, Qt::Key_Left); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); CursorPositionChangedRecorder spy2(ed); QVERIFY(ed->textCursor().position() > 0); ed->setPlainText("Hello World"); - QCOMPARE(spy2.cursorPositions.count(), 1); + QCOMPARE(spy2.cursorPositions.size(), 1); QCOMPARE(spy2.cursorPositions.at(0), 0); QCOMPARE(ed->textCursor().position(), 0); } @@ -434,7 +434,7 @@ void tst_QPlainTextEdit::setTextCursor() spy.clear(); ed->setTextCursor(cursor); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #ifndef QT_NO_CLIPBOARD @@ -451,7 +451,7 @@ void tst_QPlainTextEdit::undoAvailableAfterPaste() const QString txt("Test"); QApplication::clipboard()->setText(txt); ed->paste(); - QVERIFY(spy.count() >= 1); + QVERIFY(spy.size() >= 1); QCOMPARE(ed->toPlainText(), txt); } #endif @@ -705,16 +705,16 @@ void tst_QPlainTextEdit::noPropertiesOnDefaultTextEditCharFormat() // on a text edit. Font properties instead should be taken from the // widget's font (in sync with defaultFont property in document) and the // foreground color should be taken from the palette. - QCOMPARE(ed->textCursor().charFormat().properties().count(), 0); + QCOMPARE(ed->textCursor().charFormat().properties().size(), 0); } void tst_QPlainTextEdit::setPlainTextShouldEmitTextChangedOnce() { QSignalSpy spy(ed, SIGNAL(textChanged())); ed->setPlainText("Yankee Doodle"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); ed->setPlainText(""); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QPlainTextEdit::overwriteMode() @@ -1026,8 +1026,8 @@ void tst_QPlainTextEdit::copyAvailable() //Compare spied signals QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true", "Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort); - QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count()); - for (int i=0;i<spyCopyAvailabe.count(); i++) { + QCOMPARE(spyCopyAvailabe.size(), copyAvailable.size()); + for (int i=0;i<spyCopyAvailabe.size(); i++) { QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0); QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1()); } @@ -1063,10 +1063,10 @@ void tst_QPlainTextEdit::moveCursor() QCOMPARE(ed->textCursor().position(), 0); ed->moveCursor(QTextCursor::NextCharacter); QCOMPARE(ed->textCursor().position(), 1); - QCOMPARE(cursorMovedSpy.count(), 1); + QCOMPARE(cursorMovedSpy.size(), 1); ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); QCOMPARE(ed->textCursor().position(), 2); - QCOMPARE(cursorMovedSpy.count(), 2); + QCOMPARE(cursorMovedSpy.size(), 2); QCOMPARE(ed->textCursor().selectedText(), QString("e")); } @@ -1278,7 +1278,7 @@ void tst_QPlainTextEdit::ensureVisibleWithRtl() ed->setLayoutDirection(Qt::RightToLeft); ed->setLineWrapMode(QPlainTextEdit::NoWrap); QString txt(500, QChar(QLatin1Char('a'))); - QCOMPARE(txt.length(), 500); + QCOMPARE(txt.size(), 500); ed->setPlainText(txt); ed->resize(100, 100); ed->show(); @@ -1331,7 +1331,7 @@ void tst_QPlainTextEdit::extraSelections() ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel); QList<QTextEdit::ExtraSelection> selections = ed->extraSelections(); - QCOMPARE(selections.count(), 1); + QCOMPARE(selections.size(), 1); QCOMPARE(selections.at(0).cursor.position(), endPos); QCOMPARE(selections.at(0).cursor.anchor(), wordPos); } @@ -1461,44 +1461,44 @@ void tst_QPlainTextEdit::selectionChanged() QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 1); - QCOMPARE(selectionChangedSpy.count(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 2); - QCOMPARE(selectionChangedSpy.count(), 1); + QCOMPARE(selectionChangedSpy.size(), 1); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 3); - QCOMPARE(selectionChangedSpy.count(), 2); + QCOMPARE(selectionChangedSpy.size(), 2); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 4); - QCOMPARE(selectionChangedSpy.count(), 3); + QCOMPARE(selectionChangedSpy.size(), 3); QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 4); - QCOMPARE(selectionChangedSpy.count(), 4); + QCOMPARE(selectionChangedSpy.size(), 4); QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 5); - QCOMPARE(selectionChangedSpy.count(), 4); + QCOMPARE(selectionChangedSpy.size(), 4); } void tst_QPlainTextEdit::blockCountChanged() { QSignalSpy blockCountCpangedSpy(ed, SIGNAL(blockCountChanged(int))); ed->setPlainText("Hello"); - QCOMPARE(blockCountCpangedSpy.count(), 0); + QCOMPARE(blockCountCpangedSpy.size(), 0); ed->setPlainText("Hello World"); - QCOMPARE(blockCountCpangedSpy.count(), 0); + QCOMPARE(blockCountCpangedSpy.size(), 0); ed->setPlainText("Hello \n World \n this \n has \n more \n blocks \n than \n just \n one"); - QCOMPARE(blockCountCpangedSpy.count(), 1); + QCOMPARE(blockCountCpangedSpy.size(), 1); ed->setPlainText("One"); - QCOMPARE(blockCountCpangedSpy.count(), 2); + QCOMPARE(blockCountCpangedSpy.size(), 2); ed->setPlainText("One \n Two"); - QCOMPARE(blockCountCpangedSpy.count(), 3); + QCOMPARE(blockCountCpangedSpy.size(), 3); ed->setPlainText("Three \n Four"); - QCOMPARE(blockCountCpangedSpy.count(), 3); + QCOMPARE(blockCountCpangedSpy.size(), 3); } @@ -1699,7 +1699,7 @@ void tst_QPlainTextEdit::contextMenu() QVERIFY(!ed->findChild<QAction *>(QStringLiteral("link-copy"))); QTextCursor cursor = ed->textCursor(); - cursor.setPosition(ed->toPlainText().length() - 2); + cursor.setPosition(ed->toPlainText().size() - 2); ed->setTextCursor(cursor); menu = ed->createStandardContextMenu(ed->cursorRect().center()); @@ -1782,7 +1782,7 @@ void tst_QPlainTextEdit::updateCursorPositionAfterEdit() QTest::keyClick(&plaintextEdit, Qt::Key_Up); // The curser should move back to the end of the copied text - QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.length()); + QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.size()); } #endif diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 172c5878cb..cf74a9ae1f 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -611,7 +611,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QTest::qWait(300); QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier); QTest::qWait(300); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); // add shortcut 'keypad 5' to button2 spy1.clear(); @@ -621,8 +621,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QTest::qWait(300); QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier); QTest::qWait(300); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 1); + QCOMPARE(spy2.size(), 1); // remove shortcut from button1 spy1.clear(); @@ -632,8 +632,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QTest::qWait(300); QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier); QTest::qWait(300); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 0); + QCOMPARE(spy2.size(), 1); } #endif // QT_CONFIG(shortcut) @@ -657,16 +657,16 @@ void tst_QPushButton::emitReleasedAfterChange() QVERIFY(button1->isDown()); QTest::keyClick(&dialog, Qt::Key_Tab); QVERIFY(!button1->isDown()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); button1->setFocus(); QTest::mousePress(button1, Qt::LeftButton); QVERIFY(button1->isDown()); button1->setEnabled(false); QVERIFY(!button1->isDown()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } /* @@ -744,22 +744,22 @@ void tst_QPushButton::mousePressAndMove() QSignalSpy releaseSpy(&button, &QAbstractButton::released); QTest::mousePress(&button, Qt::LeftButton); - QCOMPARE(pressSpy.count(), 1); - QCOMPARE(releaseSpy.count(), 0); + QCOMPARE(pressSpy.size(), 1); + QCOMPARE(releaseSpy.size(), 0); // mouse pressed and moving out QTest::mouseMove(&button, QPoint(100, 100)); // should emit released signal when the mouse is dragged out of boundary - QCOMPARE(pressSpy.count(), 1); - QCOMPARE(releaseSpy.count(), 1); + QCOMPARE(pressSpy.size(), 1); + QCOMPARE(releaseSpy.size(), 1); // mouse pressed and moving into QTest::mouseMove(&button, QPoint(10, 10)); // should emit pressed signal when the mouse is dragged into of boundary - QCOMPARE(pressSpy.count(), 2); - QCOMPARE(releaseSpy.count(), 1); + QCOMPARE(pressSpy.size(), 2); + QCOMPARE(releaseSpy.size(), 1); } QTEST_MAIN(tst_QPushButton) diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index a6e39bf273..8b53c73361 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -90,7 +90,7 @@ void tst_QScrollBar::task_209492() QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int))); QCOMPARE(scrollArea.scrollCount, 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Simulate a mouse click on the "scroll down button". const QPoint pressPoint(verticalScrollBar->width() / 2, verticalScrollBar->height() - 10); @@ -109,7 +109,7 @@ void tst_QScrollBar::task_209492() QSKIP("The result depends on system setting and is not relevant on Mac"); #endif QCOMPARE(scrollArea.scrollCount, 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #if QT_CONFIG(wheelevent) @@ -159,7 +159,7 @@ void tst_QScrollBar::QTBUG_42871() QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); QVERIFY(spy.isValid()); QCOMPARE(myHandler.updatesCount, 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Simulate a mouse click on the "scroll down button". const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10); @@ -180,7 +180,7 @@ void tst_QScrollBar::QTBUG_42871() } // Check that the action was triggered once. QCOMPARE(myHandler.updatesCount, 1); - QCOMPARE(spy.count(), myHandler.updatesCount); + QCOMPARE(spy.size(), myHandler.updatesCount); } QTEST_MAIN(tst_QScrollBar) diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 732fdb6515..08b2e17ce8 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -939,38 +939,38 @@ void tst_QSpinBox::editingFinished() QTest::keyClick(box, Qt::Key_Up); QTest::keyClick(box, Qt::Key_Up); - QCOMPARE(editingFinishedSpy1.count(), 0); - QCOMPARE(editingFinishedSpy2.count(), 0); + QCOMPARE(editingFinishedSpy1.size(), 0); + QCOMPARE(editingFinishedSpy2.size(), 0); QTest::keyClick(box2, Qt::Key_Up); QTest::keyClick(box2, Qt::Key_Up); box2->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); box->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 1); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Up); - QCOMPARE(editingFinishedSpy1.count(), 1); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Enter); - QCOMPARE(editingFinishedSpy1.count(), 2); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 2); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box, Qt::Key_Return); - QCOMPARE(editingFinishedSpy1.count(), 3); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 3); + QCOMPARE(editingFinishedSpy2.size(), 1); box2->setFocus(); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 1); QTest::keyClick(box2, Qt::Key_Enter); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 2); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 2); QTest::keyClick(box2, Qt::Key_Return); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 3); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 3); testFocusWidget.hide(); - QCOMPARE(editingFinishedSpy1.count(), 4); - QCOMPARE(editingFinishedSpy2.count(), 4); + QCOMPARE(editingFinishedSpy1.size(), 4); + QCOMPARE(editingFinishedSpy2.size(), 4); //task203285 editingFinishedSpy1.clear(); @@ -987,7 +987,7 @@ void tst_QSpinBox::editingFinished() box2->setFocus(); QTRY_VERIFY(qApp->focusWidget() != box); QCOMPARE(box->text(), QLatin1String("20")); - QCOMPARE(editingFinishedSpy1.count(), 1); + QCOMPARE(editingFinishedSpy1.size(), 1); } void tst_QSpinBox::removeAll() @@ -1257,7 +1257,7 @@ void tst_QSpinBox::lineEditReturnPressed() QSignalSpy spyCurrentChanged(spinBox.lineEdit(), SIGNAL(returnPressed())); spinBox.show(); QTest::keyClick(&spinBox, Qt::Key_Return); - QCOMPARE(spyCurrentChanged.count(), 1); + QCOMPARE(spyCurrentChanged.size(), 1); } void tst_QSpinBox::positiveSign() @@ -1847,13 +1847,13 @@ void tst_QSpinBox::stepModifierPressAndHold() qDebug() << "QGuiApplication::focusWindow():" << QGuiApplication::focusWindow(); qDebug() << "QGuiApplication::topLevelWindows():" << QGuiApplication::topLevelWindows(); QTest::mousePress(&spin, Qt::LeftButton, modifiers, buttonRect.center()); - QTRY_VERIFY2(spy.length() >= 3, qPrintable(QString::fromLatin1( - "Expected valueChanged() to be emitted 3 or more times, but it was only emitted %1 times").arg(spy.length()))); + QTRY_VERIFY2(spy.size() >= 3, qPrintable(QString::fromLatin1( + "Expected valueChanged() to be emitted 3 or more times, but it was only emitted %1 times").arg(spy.size()))); QTest::mouseRelease(&spin, Qt::LeftButton, modifiers, buttonRect.center()); const auto value = spy.last().at(0); QVERIFY(value.metaType().id() == QMetaType::Int); - QCOMPARE(value.toInt(), spy.length() * expectedStepModifier); + QCOMPARE(value.toInt(), spy.size() * expectedStepModifier); } void tst_QSpinBox::stepSelectAll_data() diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index 812bfc7441..cbc1a258de 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -1063,7 +1063,7 @@ void tst_QSplitter::taskQTBUG_102249_moveNonPressed() Qt::NoButton, Qt::MouseButtons(Qt::LeftButton), Qt::NoModifier); qApp->sendEvent(s.handle(0), &me); - QCOMPARE(spyMove.count(), 0); + QCOMPARE(spyMove.size(), 0); } void tst_QSplitter::setLayout() diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp index 353c44d6b3..418dd1c0f9 100644 --- a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp +++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp @@ -272,18 +272,18 @@ void tst_QStatusBar::messageChangedSignal() testWidget->showMessage("Ready", 0); QCOMPARE(testWidget->currentMessage(), QString("Ready")); QCOMPARE(testWidget->currentMessage(), currentMessage); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage); testWidget->clearMessage(); QCOMPARE(testWidget->currentMessage(), QString()); QCOMPARE(testWidget->currentMessage(), currentMessage); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage); testWidget->showMessage("Ready", 0); testWidget->showMessage("Ready", 0); QCOMPARE(testWidget->currentMessage(), QString("Ready")); QCOMPARE(testWidget->currentMessage(), currentMessage); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage); } diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index 1e19617be9..1d7e999b10 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -209,7 +209,7 @@ void tst_QTabBar::testCurrentChanged() QCOMPARE(tabBar.currentIndex(), 0); tabBar.setCurrentIndex(tabToSet); QCOMPARE(tabBar.currentIndex(), tabToSet); - QCOMPARE(spy.count(), expectedCount); + QCOMPARE(spy.size(), expectedCount); } class TabBar : public QTabBar @@ -283,7 +283,7 @@ void tst_QTabBar::removeTab() tabbar.setCurrentIndex(currentIndex); QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int))); tabbar.removeTab(deleteIndex); - QTEST(int(spy.count()), "spyCount"); + QTEST(int(spy.size()), "spyCount"); QTEST(tabbar.currentIndex(), "finalIndex"); } @@ -314,7 +314,7 @@ void tst_QTabBar::hideTab() tabbar.setCurrentIndex(currentIndex); QSignalSpy spy(&tabbar, &QTabBar::currentChanged); tabbar.setTabVisible(hideIndex, false); - QTEST(int(spy.count()), "spyCount"); + QTEST(int(spy.size()), "spyCount"); QTEST(tabbar.currentIndex(), "finalIndex"); } @@ -458,12 +458,12 @@ void tst_QTabBar::removeLastTab() QTabBar tabbar; QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int))); int index = tabbar.addTab("foo"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), index); spy.clear(); tabbar.removeTab(index); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), -1); spy.clear(); } @@ -482,7 +482,7 @@ void tst_QTabBar::removeLastVisibleTab() { QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int))); tabbar.removeTab(visible); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), -1); QCOMPARE(tabbar.currentIndex(), -1); } @@ -495,7 +495,7 @@ void tst_QTabBar::removeLastVisibleTab() { QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int))); tabbar.removeTab(visible); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toInt(), -1); QCOMPARE(tabbar.currentIndex(), -1); } @@ -519,7 +519,7 @@ void tst_QTabBar::closeButton() QSignalSpy spy(&tabbar, SIGNAL(tabCloseRequested(int))); button->click(); QCOMPARE(tabbar.count(), 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } Q_DECLARE_METATYPE(QTabBar::ButtonPosition) @@ -791,36 +791,36 @@ void tst_QTabBar::tabBarClicked() QSignalSpy clickSpy(&tabBar, SIGNAL(tabBarClicked(int))); QSignalSpy doubleClickSpy(&tabBar, SIGNAL(tabBarDoubleClicked(int))); - QCOMPARE(clickSpy.count(), 0); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(clickSpy.size(), 0); + QCOMPARE(doubleClickSpy.size(), 0); Qt::MouseButton button = Qt::LeftButton; while (button <= Qt::MaxMouseButton) { const QPoint tabPos = tabBar.tabRect(0).center(); QTest::mouseClick(&tabBar, button, {}, tabPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(doubleClickSpy.size(), 0); QTest::mouseDClick(&tabBar, button, {}, tabPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); - QCOMPARE(doubleClickSpy.count(), 1); + QCOMPARE(doubleClickSpy.size(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0); QTest::mouseRelease(&tabBar, button, {}, tabPos); const QPoint barPos(tabBar.tabRect(0).right() + 5, tabBar.tabRect(0).center().y()); QTest::mouseClick(&tabBar, button, {}, barPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(doubleClickSpy.size(), 0); QTest::mouseDClick(&tabBar, button, {}, barPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); - QCOMPARE(doubleClickSpy.count(), 1); + QCOMPARE(doubleClickSpy.size(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1); QTest::mouseRelease(&tabBar, button, {}, barPos); diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index 0cf37ad9d0..00cb26c2d3 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -358,12 +358,12 @@ void tst_QTabWidget::currentIndex() QCOMPARE(tw->currentIndex(), -1); tw->setCurrentIndex(-1); QCOMPARE(tw->currentIndex(), -1); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); int firstIndex = addPage(); tw->setCurrentIndex(firstIndex); QCOMPARE(tw->currentIndex(), firstIndex); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), firstIndex); @@ -371,19 +371,19 @@ void tst_QTabWidget::currentIndex() QCOMPARE(tw->currentIndex(), firstIndex); tw->setCurrentIndex(index); QCOMPARE(tw->currentIndex(), index); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), index); removePage(index); QCOMPARE(tw->currentIndex(), firstIndex); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), firstIndex); removePage(firstIndex); QCOMPARE(tw->currentIndex(), -1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), -1); } @@ -664,8 +664,8 @@ void tst_QTabWidget::tabBarClicked() QSignalSpy clickSpy(&tabWidget, SIGNAL(tabBarClicked(int))); QSignalSpy doubleClickSpy(&tabWidget, SIGNAL(tabBarDoubleClicked(int))); - QCOMPARE(clickSpy.count(), 0); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(clickSpy.size(), 0); + QCOMPARE(doubleClickSpy.size(), 0); QTabBar &tabBar = *tabWidget.tabBar(); Qt::MouseButton button = Qt::LeftButton; @@ -673,27 +673,27 @@ void tst_QTabWidget::tabBarClicked() const QPoint tabPos = tabBar.tabRect(0).center(); QTest::mouseClick(&tabBar, button, {}, tabPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(doubleClickSpy.size(), 0); QTest::mouseDClick(&tabBar, button, {}, tabPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), 0); - QCOMPARE(doubleClickSpy.count(), 1); + QCOMPARE(doubleClickSpy.size(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), 0); const QPoint barPos(tabBar.tabRect(0).right() + 5, tabBar.tabRect(0).center().y()); QTest::mouseClick(&tabBar, button, {}, barPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); - QCOMPARE(doubleClickSpy.count(), 0); + QCOMPARE(doubleClickSpy.size(), 0); QTest::mouseDClick(&tabBar, button, {}, barPos); - QCOMPARE(clickSpy.count(), 1); + QCOMPARE(clickSpy.size(), 1); QCOMPARE(clickSpy.takeFirst().takeFirst().toInt(), -1); - QCOMPARE(doubleClickSpy.count(), 1); + QCOMPARE(doubleClickSpy.size(), 1); QCOMPARE(doubleClickSpy.takeFirst().takeFirst().toInt(), -1); button = Qt::MouseButton(button << 1); diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index ee950fa670..7107ed43e0 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -220,29 +220,29 @@ void tst_QTextBrowser::relativeLinks() QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl))); browser->setSource(QUrl("subdir/../qtextbrowser.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html")); browser->setSource(QUrl("subdir/index.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html")); browser->setSource(QUrl("anchor.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html")); browser->setSource(QUrl("subdir/index.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html")); // using QUrl::fromLocalFile() browser->setSource(QUrl::fromLocalFile("anchor.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html")); browser->setSource(QUrl("subdir/../qtextbrowser.html")); QVERIFY(!browser->document()->isEmpty()); - QCOMPARE(sourceChangedSpy.count(), 1); + QCOMPARE(sourceChangedSpy.size(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html")); } @@ -274,9 +274,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->setSource(QUrl::fromLocalFile("anchor.html")); QVERIFY(!browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(!backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -285,9 +285,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->setSource(QUrl::fromLocalFile("bigpage.html")); QVERIFY(browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -296,9 +296,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->setSource(QUrl::fromLocalFile("pagewithbg.html")); QVERIFY(browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -307,9 +307,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->backward(); QVERIFY(browser->isBackwardAvailable()); QVERIFY(browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -318,9 +318,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->backward(); QVERIFY(!browser->isBackwardAvailable()); QVERIFY(browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(!backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -329,9 +329,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->forward(); QVERIFY(browser->isBackwardAvailable()); QVERIFY(browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -340,9 +340,9 @@ void tst_QTextBrowser::forwardBackwardAvailable() browser->forward(); QVERIFY(browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -360,9 +360,9 @@ void tst_QTextBrowser::clearHistory() browser->clearHistory(); QVERIFY(!browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(!backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); QVERIFY(browser->historyTitle(-1).isEmpty()); QVERIFY(browser->historyTitle(0).isEmpty()); @@ -374,9 +374,9 @@ void tst_QTextBrowser::clearHistory() browser->setSource(QUrl::fromLocalFile("anchor.html")); QVERIFY(!browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(!backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -385,9 +385,9 @@ void tst_QTextBrowser::clearHistory() browser->setSource(QUrl::fromLocalFile("bigpage.html")); QVERIFY(browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); backwardSpy.clear(); @@ -396,9 +396,9 @@ void tst_QTextBrowser::clearHistory() browser->clearHistory(); QVERIFY(!browser->isBackwardAvailable()); QVERIFY(!browser->isForwardAvailable()); - QCOMPARE(backwardSpy.count(), 1); + QCOMPARE(backwardSpy.size(), 1); QVERIFY(!backwardSpy.at(0).at(0).toBool()); - QCOMPARE(forwardSpy.count(), 1); + QCOMPARE(forwardSpy.size(), 1); QVERIFY(!forwardSpy.at(0).at(0).toBool()); QVERIFY(browser->historyTitle(-1).isEmpty()); QVERIFY(browser->historyTitle(1).isEmpty()); @@ -671,7 +671,7 @@ void tst_QTextBrowser::urlEncoding() browser->setEditFocus(true); #endif QTest::keyClick(browser, Qt::Key_Enter); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QUrl url = spy.at(0).at(0).toUrl(); QCOMPARE(url.toEncoded(), QByteArray("http://www.google.com/q=%22")); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 233090e8e6..8fd5cd0d52 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -517,9 +517,9 @@ void tst_QTextEdit::clearShouldClearExtraSelections() sel.cursor = ed->textCursor(); sel.format.setProperty(QTextFormat::FullWidthSelection, true); ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel); - QCOMPARE(ed->extraSelections().count(), 1); + QCOMPARE(ed->extraSelections().size(), 1); ed->clear(); - QCOMPARE(ed->extraSelections().count(), 0); + QCOMPARE(ed->extraSelections().size(), 0); } void tst_QTextEdit::paragSeparatorOnPlaintextAppend() @@ -719,7 +719,7 @@ void tst_QTextEdit::cursorPositionChanged() spy.clear(); QTest::keyClick(ed, Qt::Key_A); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QTextCursor cursor = ed->textCursor(); cursor.movePosition(QTextCursor::Start); @@ -727,18 +727,18 @@ void tst_QTextEdit::cursorPositionChanged() cursor.movePosition(QTextCursor::End); spy.clear(); cursor.insertText("Test"); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); cursor.movePosition(QTextCursor::End); ed->setTextCursor(cursor); cursor.movePosition(QTextCursor::Start); spy.clear(); cursor.insertText("Test"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QTest::keyClick(ed, Qt::Key_Left); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); cursor.movePosition(QTextCursor::Start); ed->setTextCursor(cursor); @@ -747,12 +747,12 @@ void tst_QTextEdit::cursorPositionChanged() QTest::mouseDClick(ed->viewport(), Qt::LeftButton, {}, ed->cursorRect().center()); QVERIFY(ed->textCursor().hasSelection()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); CursorPositionChangedRecorder spy2(ed); QVERIFY(ed->textCursor().position() > 0); ed->setPlainText("Hello World"); - QCOMPARE(spy2.cursorPositions.count(), 1); + QCOMPARE(spy2.cursorPositions.size(), 1); QCOMPARE(spy2.cursorPositions.at(0), 0); QCOMPARE(ed->textCursor().position(), 0); } @@ -769,7 +769,7 @@ void tst_QTextEdit::setTextCursor() spy.clear(); ed->setTextCursor(cursor); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #ifndef QT_NO_CLIPBOARD @@ -786,7 +786,7 @@ void tst_QTextEdit::undoAvailableAfterPaste() const QString txt("Test"); QApplication::clipboard()->setText(txt); ed->paste(); - QVERIFY(spy.count() >= 1); + QVERIFY(spy.size() >= 1); QCOMPARE(ed->toPlainText(), txt); } #endif @@ -1039,7 +1039,7 @@ void tst_QTextEdit::noPropertiesOnDefaultTextEditCharFormat() // on a text edit. Font properties instead should be taken from the // widget's font (in sync with defaultFont property in document) and the // foreground color should be taken from the palette. - QCOMPARE(ed->currentCharFormat().properties().count(), 0); + QCOMPARE(ed->currentCharFormat().properties().size(), 0); } void tst_QTextEdit::setPlainTextShouldUseCurrentCharFormat() @@ -1061,9 +1061,9 @@ void tst_QTextEdit::setPlainTextShouldEmitTextChangedOnce() { QSignalSpy spy(ed, SIGNAL(textChanged())); ed->setPlainText("Yankee Doodle"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); ed->setPlainText(""); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); } void tst_QTextEdit::overwriteMode() @@ -1377,8 +1377,8 @@ void tst_QTextEdit::copyAvailable() //Compare spied signals QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true", "Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort); - QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count()); - for (int i=0;i<spyCopyAvailabe.count(); i++) { + QCOMPARE(spyCopyAvailabe.size(), copyAvailable.size()); + for (int i=0;i<spyCopyAvailabe.size(); i++) { QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0); QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1()); } @@ -1414,10 +1414,10 @@ void tst_QTextEdit::moveCursor() QCOMPARE(ed->textCursor().position(), 0); ed->moveCursor(QTextCursor::NextCharacter); QCOMPARE(ed->textCursor().position(), 1); - QCOMPARE(cursorMovedSpy.count(), 1); + QCOMPARE(cursorMovedSpy.size(), 1); ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); QCOMPARE(ed->textCursor().position(), 2); - QCOMPARE(cursorMovedSpy.count(), 2); + QCOMPARE(cursorMovedSpy.size(), 2); QCOMPARE(ed->textCursor().selectedText(), QString("e")); } @@ -1692,7 +1692,7 @@ void tst_QTextEdit::ensureVisibleWithRtl() ed->setLayoutDirection(Qt::RightToLeft); ed->setLineWrapMode(QTextEdit::NoWrap); QString txt(500, QChar(QLatin1Char('a'))); - QCOMPARE(txt.length(), 500); + QCOMPARE(txt.size(), 500); ed->setPlainText(txt); ed->resize(100, 100); ed->show(); @@ -1743,7 +1743,7 @@ void tst_QTextEdit::extraSelections() ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel); QList<QTextEdit::ExtraSelection> selections = ed->extraSelections(); - QCOMPARE(selections.count(), 1); + QCOMPARE(selections.size(), 1); QCOMPARE(selections.at(0).cursor.position(), endPos); QCOMPARE(selections.at(0).cursor.anchor(), wordPos); } @@ -1885,27 +1885,27 @@ void tst_QTextEdit::selectionChanged() QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 1); - QCOMPARE(selectionChangedSpy.count(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 2); - QCOMPARE(selectionChangedSpy.count(), 1); + QCOMPARE(selectionChangedSpy.size(), 1); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 3); - QCOMPARE(selectionChangedSpy.count(), 2); + QCOMPARE(selectionChangedSpy.size(), 2); QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(ed->textCursor().position(), 4); - QCOMPARE(selectionChangedSpy.count(), 3); + QCOMPARE(selectionChangedSpy.size(), 3); QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 4); - QCOMPARE(selectionChangedSpy.count(), 4); + QCOMPARE(selectionChangedSpy.size(), 4); QTest::keyClick(ed, Qt::Key_Right); QCOMPARE(ed->textCursor().position(), 5); - QCOMPARE(selectionChangedSpy.count(), 4); + QCOMPARE(selectionChangedSpy.size(), 4); } #ifndef QT_NO_CLIPBOARD @@ -2533,7 +2533,7 @@ void tst_QTextEdit::inputMethodEvent() QInputMethodEvent event; event.setCommitString("text"); QApplication::sendEvent(ed, &event); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(ed->toPlainText(), QString("text")); // test that input method gets chance to commit preedit when removing focus @@ -2563,7 +2563,7 @@ void tst_QTextEdit::inputMethodSelection() cursor.setPosition(5, QTextCursor::KeepAnchor); ed->setTextCursor(cursor); - QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(selectionSpy.size(), 1); QCOMPARE(ed->textCursor().selectionStart(), 0); QCOMPARE(ed->textCursor().selectionEnd(), 5); @@ -2572,7 +2572,7 @@ void tst_QTextEdit::inputMethodSelection() QInputMethodEvent event("", attributes); QApplication::sendEvent(ed, &event); - QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(selectionSpy.size(), 2); QCOMPARE(ed->textCursor().selectionStart(), 12); QCOMPARE(ed->textCursor().selectionEnd(), 17); } @@ -2587,7 +2587,7 @@ void tst_QTextEdit::inputMethodQuery() QGuiApplication::sendEvent(ed, &event); int anchor = event.value(Qt::ImAnchorPosition).toInt(); int position = event.value(Qt::ImCursorPosition).toInt(); - QCOMPARE(qAbs(position - anchor), text.length()); + QCOMPARE(qAbs(position - anchor), text.size()); QCOMPARE(event.value(Qt::ImEnabled).toBool(), true); ed->setEnabled(false); @@ -2672,7 +2672,7 @@ void tst_QTextEdit::countTextChangedOnRemove() QKeyEvent event(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); QCoreApplication::instance()->notify(&edit, &event); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #if QT_CONFIG(regularexpression) diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index c1d08316f8..e2c9f22ec2 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -137,12 +137,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::RightToolBarArea); QCOMPARE((int)tb.allowedAreas(), (int)Qt::RightToolBarArea); @@ -150,12 +150,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::TopToolBarArea); QCOMPARE((int)tb.allowedAreas(), (int)Qt::TopToolBarArea); @@ -163,12 +163,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::BottomToolBarArea); QCOMPARE((int)tb.allowedAreas(), (int)Qt::BottomToolBarArea); @@ -176,12 +176,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // multiple dock window areas tb.setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); @@ -190,12 +190,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea); QCOMPARE(tb.allowedAreas(), Qt::LeftToolBarArea | Qt::RightToolBarArea); @@ -203,12 +203,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea); QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::LeftToolBarArea); @@ -216,12 +216,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setAllowedAreas(Qt::BottomToolBarArea | Qt::RightToolBarArea); QCOMPARE(tb.allowedAreas(), Qt::BottomToolBarArea | Qt::RightToolBarArea); @@ -229,12 +229,12 @@ void tst_QToolBar::allowedAreas() QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea)); QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea)); QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea)); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()), tb.allowedAreas()); spy.clear(); tb.setAllowedAreas(tb.allowedAreas()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QToolBar::orientation() @@ -246,48 +246,48 @@ void tst_QToolBar::orientation() tb.setOrientation(Qt::Vertical); QCOMPARE(tb.orientation(), Qt::Vertical); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()), tb.orientation()); spy.clear(); tb.setOrientation(tb.orientation()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setOrientation(Qt::Horizontal); QCOMPARE(tb.orientation(), Qt::Horizontal); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()), tb.orientation()); spy.clear(); tb.setOrientation(tb.orientation()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setOrientation(Qt::Vertical); QCOMPARE(tb.orientation(), Qt::Vertical); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()), tb.orientation()); spy.clear(); tb.setOrientation(tb.orientation()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setOrientation(Qt::Horizontal); QCOMPARE(tb.orientation(), Qt::Horizontal); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()), tb.orientation()); spy.clear(); tb.setOrientation(tb.orientation()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setOrientation(Qt::Vertical); QCOMPARE(tb.orientation(), Qt::Vertical); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()), tb.orientation()); spy.clear(); tb.setOrientation(tb.orientation()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QToolBar::addAction() @@ -297,13 +297,13 @@ void tst_QToolBar::addAction() { QAction action(0); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); tb.addAction(&action); - QCOMPARE(tb.actions().count(), 1); + QCOMPARE(tb.actions().size(), 1); QCOMPARE(tb.actions()[0], &action); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } { @@ -326,14 +326,14 @@ void tst_QToolBar::addAction() QCOMPARE(icon, action4->icon()); QCOMPARE(text, action4->text()); - QCOMPARE(tb.actions().count(), 4); + QCOMPARE(tb.actions().size(), 4); QCOMPARE(tb.actions()[0], action1); QCOMPARE(tb.actions()[1], action2); QCOMPARE(tb.actions()[2], action3); QCOMPARE(tb.actions()[3], action4); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } } @@ -362,19 +362,19 @@ void tst_QToolBar::insertAction() QAction action3(0); QAction action4(0); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); tb.insertAction(0, &action1); tb.insertAction(&action1, &action2); tb.insertAction(&action2, &action3); tb.insertAction(&action3, &action4); - QCOMPARE(tb.actions().count(), 4); + QCOMPARE(tb.actions().size(), 4); QCOMPARE(tb.actions()[0], &action4); QCOMPARE(tb.actions()[1], &action3); QCOMPARE(tb.actions()[2], &action2); QCOMPARE(tb.actions()[3], &action1); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } void tst_QToolBar::addSeparator() @@ -388,13 +388,13 @@ void tst_QToolBar::addSeparator() QAction *sep = tb.addSeparator(); tb.addAction(&action2); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], sep); QCOMPARE(tb.actions()[2], &action2); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } void tst_QToolBar::insertSeparator() @@ -408,13 +408,13 @@ void tst_QToolBar::insertSeparator() tb.addAction(&action2); QAction *sep = tb.insertSeparator(&action2); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], sep); QCOMPARE(tb.actions()[2], &action2); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } void tst_QToolBar::addWidget() @@ -429,7 +429,7 @@ void tst_QToolBar::addWidget() QAction *widget = tb.addWidget(&w); tb.addAction(&action2); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], widget); QCOMPARE(tb.actions()[2], &action2); @@ -437,18 +437,18 @@ void tst_QToolBar::addWidget() // it should be possible to reuse the action returned by // addWidget() to place the widget somewhere else in the toolbar tb.removeAction(widget); - QCOMPARE(tb.actions().count(), 2); + QCOMPARE(tb.actions().size(), 2); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], &action2); tb.addAction(widget); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], &action2); QCOMPARE(tb.actions()[2], widget); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); } void tst_QToolBar::insertWidget() @@ -463,7 +463,7 @@ void tst_QToolBar::insertWidget() tb.addAction(&action2); QAction *widget = tb.insertWidget(&action2, &w); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], widget); QCOMPARE(tb.actions()[2], &action2); @@ -471,18 +471,18 @@ void tst_QToolBar::insertWidget() // it should be possible to reuse the action returned by // addWidget() to place the widget somewhere else in the toolbar tb.removeAction(widget); - QCOMPARE(tb.actions().count(), 2); + QCOMPARE(tb.actions().size(), 2); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], &action2); tb.insertAction(&action1, widget); - QCOMPARE(tb.actions().count(), 3); + QCOMPARE(tb.actions().size(), 3); QCOMPARE(tb.actions()[0], widget); QCOMPARE(tb.actions()[1], &action1); QCOMPARE(tb.actions()[2], &action2); tb.clear(); - QCOMPARE(tb.actions().count(), 0); + QCOMPARE(tb.actions().size(), 0); { QToolBar tb; @@ -624,43 +624,43 @@ void tst_QToolBar::iconSize() QCOMPARE(tb.iconSize(), defaultIconSize); tb.setIconSize(defaultIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); tb.setIconSize(largeIconSize); QCOMPARE(tb.iconSize(), largeIconSize); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.first().first().toSize(), largeIconSize); // no-op spy.clear(); tb.setIconSize(largeIconSize); QCOMPARE(tb.iconSize(), largeIconSize); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); tb.setIconSize(defaultIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.first().first().toSize(), defaultIconSize); // no-op spy.clear(); tb.setIconSize(defaultIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); spy.clear(); tb.setIconSize(smallIconSize); QCOMPARE(tb.iconSize(), smallIconSize); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.first().first().toSize(), smallIconSize); // no-op spy.clear(); tb.setIconSize(smallIconSize); QCOMPARE(tb.iconSize(), smallIconSize); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // setting the icon size to an invalid QSize will reset the // iconSize property to the default @@ -688,28 +688,28 @@ void tst_QToolBar::iconSize() // explicitly set it to the default tb.setIconSize(defaultIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.addToolBar(&tb); // tb icon size should not change since it has been explicitly set QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setIconSize(largeIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setIconSize(defaultIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setIconSize(smallIconSize); QCOMPARE(tb.iconSize(), defaultIconSize); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); // resetting to the default should cause the toolbar to take // on the mainwindow's icon size @@ -732,51 +732,51 @@ void tst_QToolBar::toolButtonStyle() QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); tb.setToolButtonStyle(Qt::ToolButtonIconOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setToolButtonStyle(Qt::ToolButtonTextOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); // no-op tb.setToolButtonStyle(Qt::ToolButtonTextOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setToolButtonStyle(Qt::ToolButtonIconOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); // no-op tb.setToolButtonStyle(Qt::ToolButtonIconOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); // no-op tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); // no-op tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.setToolButtonStyle(Qt::ToolButtonFollowStyle); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonFollowStyle); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } { @@ -790,28 +790,28 @@ void tst_QToolBar::toolButtonStyle() // explicitly set the tb to the default tb.setToolButtonStyle(Qt::ToolButtonIconOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.addToolBar(&tb); // tb icon size should not change since it has been explicitly set QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setToolButtonStyle(Qt::ToolButtonIconOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setToolButtonStyle(Qt::ToolButtonTextOnly); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); - QCOMPARE(tbSpy.count(), 0); + QCOMPARE(tbSpy.size(), 0); // note: there is no way to clear the explicitly set tool // button style... once you explicitly set it, the toolbar @@ -925,25 +925,25 @@ void tst_QToolBar::visibilityChanged() mw.addToolBar(&tb); mw.show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); tb.hide(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); tb.hide(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); tb.show(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); tb.show(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QToolBar::actionOwnership() @@ -1025,7 +1025,7 @@ void tst_QToolBar::accel() QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); #ifdef Q_OS_MAC qt_set_sequence_auto_mnemonic(false); #endif diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp index abccd7bec8..ffe1a3b687 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp @@ -122,7 +122,7 @@ void tst_QToolButton::triggered() QVERIFY(QTest::qWaitForWindowActive(&mainWidget)); defaultAction->trigger(); - QCOMPARE(spy.count(),1); + QCOMPARE(spy.size(),1); QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), defaultAction); m_menu = menu.data(); @@ -133,7 +133,7 @@ void tst_QToolButton::triggered() timer->start(); QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out toolButton->showMenu(); - QTRY_COMPARE(spy.count(),2); + QTRY_COMPARE(spy.size(),2); QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one); } @@ -186,7 +186,7 @@ void tst_QToolButton::task176137_autoRepeatOfAction() QTest::mousePress (toolButton, Qt::LeftButton); QTest::qWait(2000); QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {}); - QCOMPARE(spy.count(),1); + QCOMPARE(spy.size(),1); // try again with auto repeat toolButton->setAutoRepeat (true); @@ -196,11 +196,11 @@ void tst_QToolButton::task176137_autoRepeatOfAction() QTest::mouseRelease (toolButton, Qt::LeftButton, {}, {}); const qreal expected = (3000 - toolButton->autoRepeatDelay()) / toolButton->autoRepeatInterval() + 1; //we check that the difference is small (on some systems timers are not super accurate) - qreal diff = (expected - repeatSpy.count()) / expected; + qreal diff = (expected - repeatSpy.size()) / expected; QVERIFY2(qAbs(diff) < 0.2, qPrintable( QString("expected: %1, actual: %2, diff (fraction): %3") .arg(expected) - .arg(repeatSpy.count()) + .arg(repeatSpy.size()) .arg(diff))); } @@ -273,21 +273,21 @@ void tst_QToolButton::defaultActionSynced() tb.setChecked(true); QVERIFY(a.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), ++aToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), ++aToggledCount); tb.setChecked(false); QVERIFY(!a.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), ++aToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), ++aToggledCount); a.setChecked(true); QVERIFY(tb.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), ++aToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), ++aToggledCount); a.setChecked(false); QVERIFY(!tb.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), ++aToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), ++aToggledCount); QAction b; QSignalSpy bSpy(&b, SIGNAL(toggled(bool))); @@ -301,17 +301,17 @@ void tst_QToolButton::defaultActionSynced() QVERIFY(!a.isChecked()); QVERIFY(b.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), aToggledCount); - QCOMPARE(bSpy.count(), ++bToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), aToggledCount); + QCOMPARE(bSpy.size(), ++bToggledCount); tb.click(); QVERIFY(!a.isChecked()); QVERIFY(!tb.isChecked()); QVERIFY(!b.isChecked()); - QCOMPARE(tbSpy.count(), ++tbToggledCount); - QCOMPARE(aSpy.count(), aToggledCount); - QCOMPARE(bSpy.count(), ++bToggledCount); + QCOMPARE(tbSpy.size(), ++tbToggledCount); + QCOMPARE(aSpy.size(), aToggledCount); + QCOMPARE(bSpy.size(), ++bToggledCount); } QTEST_MAIN(tst_QToolButton) diff --git a/tests/baseline/shared/paintcommands.cpp b/tests/baseline/shared/paintcommands.cpp index 4a3de0168b..06c420e471 100644 --- a/tests/baseline/shared/paintcommands.cpp +++ b/tests/baseline/shared/paintcommands.cpp @@ -907,7 +907,7 @@ void PaintCommands::command_import(QRegularExpressionMatch re) if (m_verboseMode) { printf(" -(lance) Command buffer now looks like:\n"); - for (int i = 0; i < m_commands.count(); ++i) + for (int i = 0; i < m_commands.size(); ++i) printf(" ---> {%s}\n", qPrintable(m_commands.at(i))); } delete file; @@ -925,7 +925,7 @@ void PaintCommands::command_begin_block(QRegularExpressionMatch re) m_commands[m_currentCommandIndex] = QLatin1String("# begin block (") + blockName + QLatin1Char(')'); QStringList newBlock; int i = m_currentCommandIndex + 1; - for (; i < m_commands.count(); ++i) { + for (; i < m_commands.size(); ++i) { const QString &nextCmd = m_commands.at(i); if (nextCmd.startsWith("end_block")) { m_commands[i] = QLatin1String("# end block (") + blockName + QLatin1Char(')'); @@ -935,10 +935,10 @@ void PaintCommands::command_begin_block(QRegularExpressionMatch re) } if (m_verboseMode) - for (int j = 0; j < newBlock.count(); ++j) + for (int j = 0; j < newBlock.size(); ++j) printf(" %d: %s\n", j, qPrintable(newBlock.at(j))); - if (i >= m_commands.count()) + if (i >= m_commands.size()) printf(" - Warning! Block doesn't have an 'end_block' marker!\n"); m_blockMap.insert(blockName, newBlock); diff --git a/tests/baseline/shared/qbaselinetest.cpp b/tests/baseline/shared/qbaselinetest.cpp index 95da71d9e7..197b13a288 100644 --- a/tests/baseline/shared/qbaselinetest.cpp +++ b/tests/baseline/shared/qbaselinetest.cpp @@ -139,7 +139,7 @@ void fetchCustomClientProperties() key = line.left(colonPos).simplified().replace(' ', '_'); val = line.mid(colonPos+1).trimmed(); } - if (!key.isEmpty() && key.length() < 64 && val.length() < 256) // ###TBD: maximum 256 chars in value? + if (!key.isEmpty() && key.size() < 64 && val.size() < 256) // ###TBD: maximum 256 chars in value? addClientProperty(key, val); else qDebug() << "Unparseable script output ignored:" << line; diff --git a/tests/baseline/widgets/tst_baseline_widgets.cpp b/tests/baseline/widgets/tst_baseline_widgets.cpp index 7c09746753..23305b2044 100644 --- a/tests/baseline/widgets/tst_baseline_widgets.cpp +++ b/tests/baseline/widgets/tst_baseline_widgets.cpp @@ -1090,7 +1090,7 @@ void tst_Widgets::tst_QLineEdit() lineEdit.setAlignment(Qt::AlignCenter); QBASELINE_CHECK_DEFERRED(takeSnapshot(), "alignedCenter"); - lineEdit.setSelection(0,text.length()); + lineEdit.setSelection(0,text.size()); QBASELINE_CHECK_DEFERRED(takeSnapshot(), "textSelected"); } diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp index a1abeca12a..424ff88048 100644 --- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -43,9 +43,9 @@ void tst_QProcess::echoTest_performance() while (stopWatch.elapsed() < 2000) { process.write(array); while (process.bytesToWrite() > 0) { - int readCount = readyReadSpy.count(); + int readCount = readyReadSpy.size(); QVERIFY(process.waitForBytesWritten(5000)); - if (readyReadSpy.count() == readCount) + if (readyReadSpy.size() == readCount) QVERIFY(process.waitForReadyRead(5000)); } diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp b/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp index 3ecc700421..0711dd9244 100644 --- a/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp +++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp @@ -56,7 +56,7 @@ void tst_QMimeDatabase::inheritsPerformance() mimeTypes += mimeTypes; mimeTypes += mimeTypes; mimeTypes += mimeTypes; - QCOMPARE(mimeTypes.count(), 40); + QCOMPARE(mimeTypes.size(), 40); QMimeDatabase db; QMimeType mime = db.mimeTypeForName(QString::fromLatin1("text/x-chdr")); QVERIFY(mime.isValid()); diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp index ff651eebae..c4d4265d4f 100644 --- a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp +++ b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp @@ -274,7 +274,7 @@ void tst_QMutex::contendedNative() NativeMutexInitialize(&mutex2); QList<NativeMutexThread *> threads(threadCount); - for (int i = 0; i < threads.count(); ++i) { + for (int i = 0; i < threads.size(); ++i) { threads[i] = new NativeMutexThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes); threads[i]->start(); } @@ -286,11 +286,11 @@ void tst_QMutex::contendedNative() semaphore4.release(threadCount); } - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->done = true; semaphore1.acquire(threadCount); semaphore2.release(threadCount); - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->wait(); qDeleteAll(threads); @@ -342,7 +342,7 @@ void tst_QMutex::contendedQMutex() QMutex mutex1, mutex2; QList<QMutexThread *> threads(threadCount); - for (int i = 0; i < threads.count(); ++i) { + for (int i = 0; i < threads.size(); ++i) { threads[i] = new QMutexThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes); threads[i]->start(); } @@ -354,11 +354,11 @@ void tst_QMutex::contendedQMutex() semaphore4.release(threadCount); } - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->done = true; semaphore1.acquire(threadCount); semaphore2.release(threadCount); - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->wait(); qDeleteAll(threads); } @@ -405,7 +405,7 @@ void tst_QMutex::contendedQMutexLocker() QMutex mutex1, mutex2; QList<QMutexLockerThread *> threads(threadCount); - for (int i = 0; i < threads.count(); ++i) { + for (int i = 0; i < threads.size(); ++i) { threads[i] = new QMutexLockerThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes); threads[i]->start(); } @@ -417,11 +417,11 @@ void tst_QMutex::contendedQMutexLocker() semaphore4.release(threadCount); } - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->done = true; semaphore1.acquire(threadCount); semaphore2.release(threadCount); - for (int i = 0; i < threads.count(); ++i) + for (int i = 0; i < threads.size(); ++i) threads[i]->wait(); qDeleteAll(threads); } diff --git a/tests/benchmarks/corelib/tools/qhash/outofline.cpp b/tests/benchmarks/corelib/tools/qhash/outofline.cpp index 28c8ad6459..6ad1a4c52a 100644 --- a/tests/benchmarks/corelib/tools/qhash/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qhash/outofline.cpp @@ -7,7 +7,7 @@ QT_BEGIN_NAMESPACE size_t qHash(const Qt4String &str) { - qsizetype n = str.length(); + qsizetype n = str.size(); const QChar *p = str.unicode(); uint h = 0; diff --git a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp index ca48763538..fd0a74b52a 100644 --- a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp +++ b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp @@ -85,7 +85,7 @@ void tst_QHash::initTestCase() QByteArray id("AAAAAAA"); if (dict.isEmpty()) { - for (int i = id.length() - 1; i > 0;) { + for (int i = id.size() - 1; i > 0;) { dict.append(id); char c = id.at(i); id[i] = ++c; diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h index f29a62a8e0..03fb01f177 100644 --- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -529,13 +529,13 @@ public: m_staticTexts.append(staticText); QFontMetrics fm(p->font()); - m_size = QSize(fm.horizontalAdvance(m_text, m_text.length()), fm.height()); + m_size = QSize(fm.horizontalAdvance(m_text, m_text.size()), fm.height()); break; } case PainterQPointMode: { QFontMetrics fm(p->font()); - m_size = QSize(fm.horizontalAdvance(m_text, m_text.length()), fm.height()); + m_size = QSize(fm.horizontalAdvance(m_text, m_text.size()), fm.height()); break; } @@ -576,7 +576,7 @@ public: QString name() const override { - int letters = m_text.length(); + int letters = m_text.size(); int lines = m_text.count('\n'); if (lines == 0) lines = 1; diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index e16d1f313b..066c981455 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -95,7 +95,7 @@ void tst_QGraphicsLayout::invalidate() QBENCHMARK { leaf->setMinimumSize(size); leaf->setMaximumSize(size); - while (setGeometryCalls->count() < depth) { + while (setGeometryCalls->size() < depth) { QApplication::sendPostedEvents(); } // force a resize on each widget, this will ensure |