summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-03-15 13:02:07 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2022-03-15 20:18:56 +0100
commit6eda249402d2b32c2ecb5f25cde490e2ddcad7a2 (patch)
tree8cdf74b938f617dd6033bd6f89abaffc035bb1e5
parente494b39b337b26c44e4474cfde78f20d721ce83b (diff)
Fix deprecated use of QBA/Q*String::count
'Use size() or length() instead' Change-Id: I284fce29727c4c1ec9ea38a4e8ea13a9e0af5390 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/dbus/qdbusutil.cpp2
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/rhi/qrhigles2.cpp6
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp2
-rw-r--r--src/gui/text/qtextodfwriter.cpp6
-rw-r--r--src/network/access/qhttpmultipart.cpp24
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/plugins/tls/openssl/qsslcontext_openssl.cpp2
-rw-r--r--src/plugins/tls/openssl/qtlskey_openssl.cpp4
-rw-r--r--src/plugins/tls/shared/qtlskey_generic.cpp4
-rw-r--r--src/testlib/qplaintestlogger.cpp12
-rw-r--r--src/widgets/accessible/simplewidgets.cpp4
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp2
16 files changed, 40 insertions, 40 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index fbde6b69fd..5fba6619e6 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1089,7 +1089,7 @@ void QDir::setSearchPaths(const QString &prefix, const QStringList &searchPaths)
return;
}
- for (int i = 0; i < prefix.count(); ++i) {
+ for (int i = 0; i < prefix.length(); ++i) {
if (!prefix.at(i).isLetterOrNumber()) {
qWarning("QDir::setSearchPaths: Prefix can only contain letters or numbers");
return;
diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp
index 8322ff02c4..96293ccd3c 100644
--- a/src/dbus/qdbusutil.cpp
+++ b/src/dbus/qdbusutil.cpp
@@ -93,7 +93,7 @@ static bool variantToString(const QVariant &arg, QString &out)
} else if (argType == QMetaType::QByteArray) {
out += QLatin1Char('{');
QByteArray list = arg.toByteArray();
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.length(); ++i) {
out += QString::number(list.at(i));
out += QLatin1String(", ");
}
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 2b428784c0..e8a6225fd7 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1031,7 +1031,7 @@ int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
// in them.. (Let's hope no one translate with a comma in it:)
p = keyseq.indexOf(QLatin1Char(','));
if (-1 != p) {
- if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
+ if (p == keyseq.length() - 1) { // Last comma 'Ctrl+,'
p = -1;
} else {
if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index adb6614336..09425e0bb3 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -1384,7 +1384,7 @@ QByteArray QRhiGles2::pipelineCacheData()
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.count()));
+ const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.length()));
if (driverStrLen)
memcpy(header.driver, driverInfoStruct.deviceName.constData(), driverStrLen);
header.driver[driverStrLen] = '\0';
@@ -1456,7 +1456,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.count()));
+ const size_t driverStrLen = qMin(sizeof(header.driver) - 1, size_t(driverInfoStruct.deviceName.length()));
if (strncmp(header.driver, driverInfoStruct.deviceName.constData(), driverStrLen)) {
qWarning("setPipelineCacheData: OpenGL vendor/renderer/version does not match");
return;
@@ -4348,7 +4348,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.count();
+ const GLint srcLength = source.length();
f->glShaderSource(shader, 1, &srcStr, &srcLength);
f->glCompileShader(shader);
GLint compiled = 0;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 9e294d083e..b8e1c8869a 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3198,7 +3198,7 @@ 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.count();
+ int tabSectionEnd = layoutData->string.length();
if (tabSpec.type == QTextOption::RightTab || tabSpec.type == QTextOption::CenterTab) {
// find next tab to calculate the width required.
tab = QFixed::fromReal(tabSpec.position);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 2494fa472c..bb15feabfa 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1525,7 +1525,7 @@ void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDo
bool QTextHtmlParserNode::hasOnlyWhitespace() const
{
- for (int i = 0; i < text.count(); ++i)
+ for (int i = 0; i < text.length(); ++i)
if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator)
return false;
return true;
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index e36061ee9d..4e3e8a6fd9 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -360,8 +360,8 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
bool escapeNextSpace = true;
int precedingSpaces = 0;
int exportedIndex = 0;
- for (int i=0; i <= fragmentText.count(); ++i) {
- QChar character = (i == fragmentText.count() ? QChar() : fragmentText.at(i));
+ for (int i=0; i <= fragmentText.length(); ++i) {
+ QChar character = (i == fragmentText.length() ? QChar() : fragmentText.at(i));
bool isSpace = character.unicode() == ' ';
// find more than one space. -> <text:s text:c="2" />
@@ -377,7 +377,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
exportedIndex = i;
}
- if (i < fragmentText.count()) {
+ if (i < fragmentText.length()) {
if (character.unicode() == 0x2028) { // soft-return
//if (exportedIndex < i)
writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
diff --git a/src/network/access/qhttpmultipart.cpp b/src/network/access/qhttpmultipart.cpp
index 6ae4f5daee..951dc6cc7f 100644
--- a/src/network/access/qhttpmultipart.cpp
+++ b/src/network/access/qhttpmultipart.cpp
@@ -353,11 +353,11 @@ void QHttpMultiPart::setBoundary(const QByteArray &boundary)
qint64 QHttpPartPrivate::bytesAvailable() const
{
checkHeaderCreated();
- qint64 bytesAvailable = header.count();
+ qint64 bytesAvailable = header.length();
if (bodyDevice) {
bytesAvailable += bodyDevice->bytesAvailable() - readPointer;
} else {
- bytesAvailable += body.count() - readPointer;
+ bytesAvailable += body.length() - readPointer;
}
// the device might have closed etc., so make sure we do not return a negative value
return qMax(bytesAvailable, (qint64) 0);
@@ -367,7 +367,7 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize)
{
checkHeaderCreated();
qint64 bytesRead = 0;
- qint64 headerDataCount = header.count();
+ qint64 headerDataCount = header.length();
// read header if it has not been read yet
if (readPointer < headerDataCount) {
@@ -385,7 +385,7 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize)
bytesRead += dataBytesRead;
readPointer += dataBytesRead;
} else {
- qint64 contentBytesRead = qMin(body.count() - readPointer + headerDataCount, maxSize - bytesRead);
+ qint64 contentBytesRead = qMin(body.length() - 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:
@@ -400,11 +400,11 @@ qint64 QHttpPartPrivate::readData(char *data, qint64 maxSize)
qint64 QHttpPartPrivate::size() const
{
checkHeaderCreated();
- qint64 size = header.count();
+ qint64 size = header.length();
if (bodyDevice) {
size += bodyDevice->size();
} else {
- size += body.count();
+ size += body.length();
}
return size;
}
@@ -440,7 +440,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.count() <= 70);
+ Q_ASSERT(boundary.length() <= 70);
}
qint64 QHttpMultiPartIODevice::size() const
@@ -449,7 +449,7 @@ qint64 QHttpMultiPartIODevice::size() const
// including boundary (needed later in readData)
if (deviceSize == -1) {
qint64 currentSize = 0;
- qint64 boundaryCount = multiPart->boundary.count();
+ qint64 boundaryCount = multiPart->boundary.length();
for (int a = 0; a < multiPart->parts.count(); a++) {
partOffsets.append(currentSize);
// 4 additional bytes for the "--" before and the "\r\n" after the boundary,
@@ -491,7 +491,7 @@ qint64 QHttpMultiPartIODevice::readData(char *data, qint64 maxSize)
// skip the parts we have already read
while (index < multiPart->parts.count() &&
readPointer >= partOffsets.at(index) + multiPart->parts.at(index).d->size()
- + multiPart->boundary.count() + 6) // 6 == 2 boundary dashes, \r\n after boundary, \r\n after multipart
+ + multiPart->boundary.length() + 6) // 6 == 2 boundary dashes, \r\n after boundary, \r\n after multipart
index++;
// read the data
@@ -499,7 +499,7 @@ qint64 QHttpMultiPartIODevice::readData(char *data, qint64 maxSize)
// check whether we need to read the boundary of the current part
QByteArray boundaryData = "--" + multiPart->boundary + "\r\n";
- qint64 boundaryCount = boundaryData.count();
+ qint64 boundaryCount = boundaryData.length();
qint64 partIndex = readPointer - partOffsets.at(index);
if (partIndex < boundaryCount) {
qint64 boundaryBytesRead = qMin(boundaryCount - partIndex, maxSize - bytesRead);
@@ -532,8 +532,8 @@ qint64 QHttpMultiPartIODevice::readData(char *data, qint64 maxSize)
// check whether we need to return the final boundary
if (bytesRead < maxSize && index == multiPart->parts.count()) {
QByteArray finalBoundary = "--" + multiPart->boundary + "--\r\n";
- qint64 boundaryIndex = readPointer + finalBoundary.count() - size();
- qint64 lastBoundaryBytesRead = qMin(finalBoundary.count() - boundaryIndex, maxSize - bytesRead);
+ qint64 boundaryIndex = readPointer + finalBoundary.length() - size();
+ qint64 lastBoundaryBytesRead = qMin(finalBoundary.length() - boundaryIndex, maxSize - bytesRead);
memcpy(data + bytesRead, finalBoundary.constData() + boundaryIndex, lastBoundaryBytesRead);
bytesRead += lastBoundaryBytesRead;
readPointer += lastBoundaryBytesRead;
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index b04f0cba7a..e1d978af11 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1666,7 +1666,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.count());
+ contentType.reserve(34 + multiPart->d_func()->boundary.length());
contentType += "multipart/";
switch (multiPart->d_func()->contentType) {
case QHttpMultiPart::RelatedType:
diff --git a/src/plugins/tls/openssl/qsslcontext_openssl.cpp b/src/plugins/tls/openssl/qsslcontext_openssl.cpp
index 0ed0590409..37030794ad 100644
--- a/src/plugins/tls/openssl/qsslcontext_openssl.cpp
+++ b/src/plugins/tls/openssl/qsslcontext_openssl.cpp
@@ -266,7 +266,7 @@ SSL* QSslContext::createSsl()
}
if (m_supportedNPNVersions.size()) {
m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data());
- m_npnContext.len = m_supportedNPNVersions.count();
+ m_npnContext.len = m_supportedNPNVersions.length();
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
diff --git a/src/plugins/tls/openssl/qtlskey_openssl.cpp b/src/plugins/tls/openssl/qtlskey_openssl.cpp
index 08b806a74d..a394f7c96d 100644
--- a/src/plugins/tls/openssl/qtlskey_openssl.cpp
+++ b/src/plugins/tls/openssl/qtlskey_openssl.cpp
@@ -160,7 +160,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.count()) {
+ while (i < der.length()) {
int j = der.indexOf(':', i); // field-name
if (j == -1)
break;
@@ -179,7 +179,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.count() && (der.at(i) == ' ' || der.at(i) == '\t'));
+ } while (i < der.length() && (der.at(i) == ' ' || der.at(i) == '\t'));
if (i == -1)
break; // something is wrong
diff --git a/src/plugins/tls/shared/qtlskey_generic.cpp b/src/plugins/tls/shared/qtlskey_generic.cpp
index 495ccec681..a4acfa3e74 100644
--- a/src/plugins/tls/shared/qtlskey_generic.cpp
+++ b/src/plugins/tls/shared/qtlskey_generic.cpp
@@ -770,7 +770,7 @@ QByteArray TlsKeyGeneric::derFromPem(const QByteArray &pem, QMap<QByteArray, QBy
if (der.contains("Proc-Type:")) {
// taken from QHttpNetworkReplyPrivate::parseHeader
int i = 0;
- while (i < der.count()) {
+ while (i < der.length()) {
int j = der.indexOf(':', i); // field-name
if (j == -1)
break;
@@ -789,7 +789,7 @@ QByteArray TlsKeyGeneric::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.count() && (der.at(i) == ' ' || der.at(i) == '\t'));
+ } while (i < der.length() && (der.at(i) == ' ' || der.at(i) == '\t'));
if (i == -1)
break; // something is wrong
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index 19d615b157..d5296eae79 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -154,10 +154,10 @@ namespace QTest {
QString beforeDecimalPoint = QString::number(qint64(number), 'f', 0);
QString afterDecimalPoint = QString::number(number, 'f', 20);
- afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1);
+ afterDecimalPoint.remove(0, beforeDecimalPoint.length() + 1);
- int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits);
- int beforeRemove = beforeDecimalPoint.count() - beforeUse;
+ int beforeUse = qMin(beforeDecimalPoint.length(), significantDigits);
+ int beforeRemove = beforeDecimalPoint.length() - beforeUse;
// Replace insignificant digits before the decimal point with zeros.
beforeDecimalPoint.chop(beforeRemove);
@@ -172,14 +172,14 @@ namespace QTest {
++afterUse;
int i = 0;
- while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0')) {
+ while (i < afterDecimalPoint.length() && afterDecimalPoint.at(i) == QLatin1Char('0')) {
++i;
}
afterUse += i;
}
- int afterRemove = afterDecimalPoint.count() - afterUse;
+ int afterRemove = afterDecimalPoint.length() - afterUse;
afterDecimalPoint.chop(afterRemove);
QChar separator = QLatin1Char(',');
@@ -207,7 +207,7 @@ namespace QTest {
int formatResult(char * buffer, int bufferSize, T number, int significantDigits)
{
QString result = formatResult(number, significantDigits);
- int size = result.count();
+ int size = result.length();
qstrncpy(buffer, std::move(result).toLatin1().constData(), bufferSize);
return size;
}
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index 3ecd938039..0d4556adc5 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -811,7 +811,7 @@ void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *e
return;
*startOffset = lineEdit()->selectionStart();
- *endOffset = *startOffset + lineEdit()->selectedText().count();
+ *endOffset = *startOffset + lineEdit()->selectedText().length();
}
QString QAccessibleLineEdit::text(int startOffset, int endOffset) const
@@ -884,7 +884,7 @@ void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int
int QAccessibleLineEdit::characterCount() const
{
- return lineEdit()->text().count();
+ return lineEdit()->text().length();
}
void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex)
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 89ecaab81d..4e460026a4 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -3840,8 +3840,8 @@ void QFileDialogPrivate::_q_useNameFilter(int index)
QString fileName = lineEdit()->text();
const QString fileNameExtension = QFileInfo(fileName).suffix();
if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
- const int fileNameExtensionLength = fileNameExtension.count();
- fileName.replace(fileName.count() - fileNameExtensionLength,
+ const int fileNameExtensionLength = fileNameExtension.length();
+ fileName.replace(fileName.length() - fileNameExtensionLength,
fileNameExtensionLength, newNameFilterExtension);
qFileDialogUi->listView->clearSelection();
lineEdit()->setText(fileName);
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 6ae621a85b..b325b5d8eb 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -748,7 +748,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.count(); i++) {
+ for (int i = 0; i < layout.length(); i++) {
int button = layout[i].toLatin1();
switch (button) {
case 'm':