diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 08:17:22 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 18:20:17 +0200 |
commit | c338447261878111df7198fbd96051926464e865 (patch) | |
tree | d21b5af1efae225f75d5c05dfe370daefb1ea1d1 /src/linguist | |
parent | 6495329e6de803025e6e4e8291b648f94893551c (diff) | |
download | qttools-c338447261878111df7198fbd96051926464e865.tar.gz |
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: I95f6410e57a6a92b1cf91bbedfbe3d517cab6b44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/linguist')
32 files changed, 252 insertions, 252 deletions
diff --git a/src/linguist/linguist/batchtranslationdialog.cpp b/src/linguist/linguist/batchtranslationdialog.cpp index 639ca1b58..c3c9ea8b2 100644 --- a/src/linguist/linguist/batchtranslationdialog.cpp +++ b/src/linguist/linguist/batchtranslationdialog.cpp @@ -47,7 +47,7 @@ void BatchTranslationDialog::setPhraseBooks(const QList<PhraseBook *> &phraseboo m_model.insertColumn(0); m_phrasebooks = phrasebooks; m_modelIndex = modelIndex; - int count = phrasebooks.count(); + int count = phrasebooks.size(); m_model.insertRows(0, count); for (int i = 0; i < count; ++i) { QModelIndex idx(m_model.index(i, 0)); diff --git a/src/linguist/linguist/main.cpp b/src/linguist/linguist/main.cpp index 4c60e8482..39535c3b3 100644 --- a/src/linguist/linguist/main.cpp +++ b/src/linguist/linguist/main.cpp @@ -76,10 +76,10 @@ int main(int argc, char **argv) QString resourceDir = QLibraryInfo::path(QLibraryInfo::TranslationsPath); QStringList args = app.arguments(); - for (int i = 1; i < args.count(); ++i) { + for (int i = 1; i < args.size(); ++i) { QString argument = args.at(i); if (argument == QLatin1String("-resourcedir")) { - if (i + 1 < args.count()) { + if (i + 1 < args.size()) { resourceDir = QFile::decodeName(args.at(++i).toLocal8Bit()); } else { // issue a warning diff --git a/src/linguist/linguist/mainwindow.cpp b/src/linguist/linguist/mainwindow.cpp index f640809c6..28803049e 100644 --- a/src/linguist/linguist/mainwindow.cpp +++ b/src/linguist/linguist/mainwindow.cpp @@ -106,7 +106,7 @@ static Ending ending(QString str, QLocale::Language lang) if (str.isEmpty()) return End_None; - switch (str.at(str.length() - 1).unicode()) { + switch (str.at(str.size() - 1).unicode()) { case 0x002e: // full stop if (str.endsWith(QLatin1String("..."))) return End_Ellipsis; @@ -1180,7 +1180,7 @@ void MainWindow::openPhraseBook() m_phraseBookDir = QFileInfo(name).absolutePath(); if (!isPhraseBookOpen(name)) { if (PhraseBook *phraseBook = doOpenPhraseBook(name)) { - int n = phraseBook->phrases().count(); + int n = phraseBook->phrases().size(); statusBar()->showMessage(tr("%n phrase(s) loaded.", 0, n), MessageMS); } } @@ -2407,7 +2407,7 @@ void MainWindow::updatePhraseDictInternal(int model) const auto phrases = pb->phrases(); for (Phrase *p : phrases) { QString f = friendlyString(p->source()); - if (f.length() > 0) { + if (f.size() > 0) { f = f.split(QLatin1Char(' ')).first(); if (!pd.contains(f)) { pd.insert(f, QList<Phrase *>()); @@ -2488,7 +2488,7 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) QStringList translations = m->translations(); // Truncated variants are permitted to be "denormalized" - for (int i = 0; i < translations.count(); ++i) { + for (int i = 0; i < translations.size(); ++i) { int sep = translations.at(i).indexOf(QChar(Translator::BinaryVariantSeparator)); if (sep >= 0) translations[i].truncate(sep); @@ -2497,7 +2497,7 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) if (m_ui.actionAccelerators->isChecked()) { bool sk = haveMnemonic(source); bool tk = true; - for (int i = 0; i < translations.count() && tk; ++i) { + for (int i = 0; i < translations.size() && tk; ++i) { tk &= haveMnemonic(translations[i]); } @@ -2513,7 +2513,7 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) } if (m_ui.actionSurroundingWhitespace->isChecked()) { bool whitespaceok = true; - for (int i = 0; i < translations.count() && whitespaceok; ++i) { + for (int i = 0; i < translations.size() && whitespaceok; ++i) { whitespaceok &= (leadingWhitespace(source) == leadingWhitespace(translations[i])); whitespaceok &= (trailingWhitespace(source) == trailingWhitespace(translations[i])); } @@ -2526,7 +2526,7 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) } if (m_ui.actionEndingPunctuation->isChecked()) { bool endingok = true; - for (int i = 0; i < translations.count() && endingok; ++i) { + for (int i = 0; i < translations.size() && endingok; ++i) { endingok &= (ending(source, m_dataModel->sourceLanguage(mi)) == ending(translations[i], m_dataModel->language(mi))); } @@ -2577,14 +2577,14 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) // between place markers in the source text and the translation text. QHash<int, int> placeMarkerIndexes; QString translation; - int numTranslations = translations.count(); + int numTranslations = translations.size(); for (int pass = 0; pass < numTranslations + 1; ++pass) { const QChar *uc_begin = source.unicode(); - const QChar *uc_end = uc_begin + source.length(); + const QChar *uc_end = uc_begin + source.size(); if (pass >= 1) { translation = translations[pass - 1]; uc_begin = translation.unicode(); - uc_end = uc_begin + translation.length(); + uc_end = uc_begin + translation.size(); } const QChar *c = uc_begin; while (c < uc_end) { diff --git a/src/linguist/linguist/messageeditor.cpp b/src/linguist/linguist/messageeditor.cpp index 5d9588055..3939ada5a 100644 --- a/src/linguist/linguist/messageeditor.cpp +++ b/src/linguist/linguist/messageeditor.cpp @@ -236,7 +236,7 @@ void MessageEditor::addPluralForm(int model, const QString &label, bool writable transEditor->setVisible(false); transEditor->setMultiEnabled(m_lengthVariants); static_cast<QBoxLayout *>(m_editors[model].container->layout())->insertWidget( - m_editors[model].transTexts.count(), transEditor); + m_editors[model].transTexts.size(), transEditor); connect(transEditor, &FormMultiWidget::selectionChanged, this, &MessageEditor::selectionChanged); @@ -315,7 +315,7 @@ void MessageEditor::reallyFixTabOrder() QStringList MessageEditor::translations(int model) const { QStringList translations; - for (int i = 0; i < m_editors[model].transTexts.count() && + for (int i = 0; i < m_editors[model].transTexts.size() && m_editors[model].transTexts.at(i)->isVisible(); ++i) translations << m_editors[model].transTexts[i]->getTranslation(); return translations; @@ -376,8 +376,8 @@ void MessageEditor::resetSelection() void MessageEditor::activeModelAndNumerus(int *model, int *numerus) const { - for (int j = 0; j < m_editors.count(); ++j) { - for (int i = 0; i < m_editors[j].transTexts.count(); ++i) + for (int j = 0; j < m_editors.size(); ++j) { + for (int i = 0; i < m_editors[j].transTexts.size(); ++i) for (QTextEdit *te : m_editors[j].transTexts[i]->getEditors()) if (m_focusWidget == te) { *model = j; @@ -443,11 +443,11 @@ void MessageEditor::setTargetLanguage(int model) { const QStringList &numerusForms = m_dataModel->model(model)->numerusForms(); const QString &langLocalized = m_dataModel->model(model)->localizedLanguage(); - for (int i = 0; i < numerusForms.count(); ++i) { + for (int i = 0; i < numerusForms.size(); ++i) { const QString &label = tr("Translation to %1 (%2)").arg(langLocalized, numerusForms[i]); if (!i) m_editors[model].firstForm = label; - if (i >= m_editors[model].transTexts.count()) + if (i >= m_editors[model].transTexts.size()) addPluralForm(model, label, m_dataModel->isModelWritable(model)); else m_editors[model].transTexts[i]->setLabel(label); @@ -456,7 +456,7 @@ void MessageEditor::setTargetLanguage(int model) tr("This is where you can enter or modify" " the translation of the above source text.") ); } - for (int j = m_editors[model].transTexts.count() - numerusForms.count(); j > 0; --j) + for (int j = m_editors[model].transTexts.size() - numerusForms.size(); j > 0; --j) delete m_editors[model].transTexts.takeLast(); m_editors[model].invariantForm = tr("Translation to %1").arg(langLocalized); m_editors[model].transCommentText->setLabel(tr("Translator comments for %1").arg(langLocalized)); @@ -464,8 +464,8 @@ void MessageEditor::setTargetLanguage(int model) MessageEditorData *MessageEditor::modelForWidget(const QObject *o) { - for (int j = 0; j < m_editors.count(); ++j) { - for (int i = 0; i < m_editors[j].transTexts.count(); ++i) + for (int j = 0; j < m_editors.size(); ++j) { + for (int i = 0; i < m_editors[j].transTexts.size(); ++i) for (QTextEdit *te : m_editors[j].transTexts[i]->getEditors()) if (te == o) return &m_editors[j]; @@ -547,7 +547,7 @@ void MessageEditor::showNothing() m_source->clearTranslation(); m_pluralSource->clearTranslation(); m_commentText->clearTranslation(); - for (int j = 0; j < m_editors.count(); ++j) { + for (int j = 0; j < m_editors.size(); ++j) { setEditingEnabled(j, false); for (FormMultiWidget *widget : qAsConst(m_editors[j].transTexts)) widget->clearTranslation(); @@ -608,7 +608,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index) && item->message().type() != TranslatorMessage::Vanished); // Translation label - ed.pluralEditMode = item->translations().count() > 1; + ed.pluralEditMode = item->translations().size() > 1; ed.transTexts.first()->setLabel(ed.pluralEditMode ? ed.firstForm : ed.invariantForm); // Translation forms @@ -619,7 +619,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index) QStringList normalizedTranslations = m_dataModel->model(j)->normalizedTranslations(*item); for (int i = 0; i < ed.transTexts.size(); ++i) { - bool shouldShow = (i < normalizedTranslations.count()); + bool shouldShow = (i < normalizedTranslations.size()); if (shouldShow) setNumerusTranslation(j, normalizedTranslations.at(i), i); else @@ -637,7 +637,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index) void MessageEditor::setNumerusTranslation(int model, const QString &translation, int numerus) { MessageEditorData &ed = m_editors[model]; - if (numerus >= ed.transTexts.count()) + if (numerus >= ed.transTexts.size()) numerus = 0; FormMultiWidget *transForm = ed.transTexts[numerus]; transForm->setTranslation(translation, false); @@ -836,7 +836,7 @@ void MessageEditor::setEditorFocusForModel(int model) bool MessageEditor::focusNextUnfinished(int start) { - for (int j = start; j < m_editors.count(); ++j) + for (int j = start; j < m_editors.size(); ++j) if (m_dataModel->isModelWritable(j)) if (MessageItem *item = m_dataModel->messageItem(m_currentIndex, j)) if (item->type() == TranslatorMessage::Unfinished) { diff --git a/src/linguist/linguist/messageeditor.h b/src/linguist/linguist/messageeditor.h index 8f996cc5b..6f2442e74 100644 --- a/src/linguist/linguist/messageeditor.h +++ b/src/linguist/linguist/messageeditor.h @@ -46,7 +46,7 @@ public: void setNumerusForms(int model, const QStringList &numerusForms); bool eventFilter(QObject *, QEvent *) override; void setNumerusTranslation(int model, const QString &translation, int numerus); - int activeModel() const { return (m_editors.count() != 1) ? m_currentModel : 0; } + int activeModel() const { return (m_editors.size() != 1) ? m_currentModel : 0; } void setEditorFocusForModel(int model); void setUnfinishedEditorFocus(); bool focusNextUnfinished(); diff --git a/src/linguist/linguist/messageeditorwidgets.cpp b/src/linguist/linguist/messageeditorwidgets.cpp index 34559fb8c..25969ca68 100644 --- a/src/linguist/linguist/messageeditorwidgets.cpp +++ b/src/linguist/linguist/messageeditorwidgets.cpp @@ -273,7 +273,7 @@ bool FormMultiWidget::eventFilter(QObject *watched, QEvent *event) { int i = 0; while (m_editors.at(i) != watched) - if (++i >= m_editors.count()) // Happens when deleting an editor + if (++i >= m_editors.size()) // Happens when deleting an editor return false; if (event->type() == QEvent::FocusOut) { m_minusButtons.at(i)->setToolTip(QString()); @@ -315,7 +315,7 @@ void FormMultiWidget::updateLayout() if (variants) { QVBoxLayout *layoutForPlusButtons = new QVBoxLayout; layoutForPlusButtons->setContentsMargins(QMargins()); - for (int i = 0; i < m_plusButtons.count(); ++i) + for (int i = 0; i < m_plusButtons.size(); ++i) layoutForPlusButtons->addWidget(m_plusButtons.at(i), Qt::AlignTop); layout->addLayout(layoutForPlusButtons, 1, 0, Qt::AlignTop); @@ -323,20 +323,20 @@ void FormMultiWidget::updateLayout() QGridLayout *layoutForLabels = new QGridLayout; layoutForLabels->setContentsMargins(QMargins()); layoutForLabels->setRowMinimumHeight(0, minimumRowHeight); - for (int j = 0; j < m_editors.count(); ++j) { + for (int j = 0; j < m_editors.size(); ++j) { layoutForLabels->addWidget(m_editors.at(j), 1 + j, 0, Qt::AlignVCenter); layoutForLabels->addWidget(m_minusButtons.at(j), 1 + j, 1, Qt::AlignVCenter); } - layoutForLabels->setRowMinimumHeight(m_editors.count() + 1, minimumRowHeight); + layoutForLabels->setRowMinimumHeight(m_editors.size() + 1, minimumRowHeight); layout->addLayout(layoutForLabels, 1, 1, Qt::AlignTop); } else { - for (int k = 0; k < m_editors.count(); ++k) + for (int k = 0; k < m_editors.size(); ++k) layout->addWidget(m_editors.at(k), 1 + k, 0, Qt::AlignVCenter); } - for (int i = 0; i < m_plusButtons.count(); ++i) + for (int i = 0; i < m_plusButtons.size(); ++i) m_plusButtons.at(i)->setVisible(variants); - for (int j = 0; j < m_minusButtons.count(); ++j) + for (int j = 0; j < m_minusButtons.size(); ++j) m_minusButtons.at(j)->setVisible(variants); updateGeometry(); @@ -356,16 +356,16 @@ void FormMultiWidget::setTranslation(const QString &text, bool userAction) { QStringList texts = text.split(QChar(Translator::BinaryVariantSeparator), Qt::KeepEmptyParts); - while (m_editors.count() > texts.count()) { + while (m_editors.size() > texts.size()) { delete m_minusButtons.takeLast(); delete m_plusButtons.takeLast(); delete m_editors.takeLast(); } - while (m_editors.count() < texts.count()) - addEditor(m_editors.count()); + while (m_editors.size() < texts.size()) + addEditor(m_editors.size()); updateLayout(); - for (int i = 0; i < texts.count(); ++i) + for (int i = 0; i < texts.size(); ++i) // XXX this will emit n textChanged signals m_editors.at(i)->setPlainText(texts.at(i), userAction); @@ -397,7 +397,7 @@ QString toPlainText(const QString &text) QString FormMultiWidget::getTranslation() const { QString ret; - for (int i = 0; i < m_editors.count(); ++i) { + for (int i = 0; i < m_editors.size(); ++i) { if (i) ret += QChar(Translator::BinaryVariantSeparator); ret += toPlainText(m_editors.at(i)->document()->toRawText()); @@ -408,7 +408,7 @@ QString FormMultiWidget::getTranslation() const void FormMultiWidget::setEditingEnabled(bool enable) { // Use read-only state so that the text can still be copied - for (int i = 0; i < m_editors.count(); ++i) + for (int i = 0; i < m_editors.size(); ++i) m_editors.at(i)->setReadOnly(!enable); m_label->setEnabled(enable); if (m_multiEnabled) @@ -441,7 +441,7 @@ void FormMultiWidget::plusButtonClicked() void FormMultiWidget::deleteEditor(int idx) { - if (m_editors.count() == 1) { + if (m_editors.size() == 1) { // Don't just clear(), so the undo history is not lost QTextCursor c = m_editors.first()->textCursor(); c.select(QTextCursor::Document); @@ -458,7 +458,7 @@ void FormMultiWidget::deleteEditor(int idx) delete m_minusButtons.takeAt(idx); delete m_plusButtons.takeAt(idx + 1); updateLayout(); - emit textChanged(m_editors.at((m_editors.count() == idx) ? idx - 1 : idx)); + emit textChanged(m_editors.at((m_editors.size() == idx) ? idx - 1 : idx)); } } diff --git a/src/linguist/linguist/messagehighlighter.cpp b/src/linguist/linguist/messagehighlighter.cpp index c63744739..1812b6bfa 100644 --- a/src/linguist/linguist/messagehighlighter.cpp +++ b/src/linguist/linguist/messagehighlighter.cpp @@ -60,7 +60,7 @@ void MessageHighlighter::highlightBlock(const QString &text) static const QLatin1String endElement = QLatin1String("/>"); int state = previousBlockState(); - int len = text.length(); + int len = text.size(); int start = 0; int pos = 0; diff --git a/src/linguist/linguist/messagemodel.cpp b/src/linguist/linguist/messagemodel.cpp index 35e157877..d390773fb 100644 --- a/src/linguist/linguist/messagemodel.cpp +++ b/src/linguist/linguist/messagemodel.cpp @@ -64,9 +64,9 @@ void ContextItem::appendToComment(const QString &str) MessageItem *ContextItem::messageItem(int i) const { - if (i >= 0 && i < msgItemList.count()) + if (i >= 0 && i < msgItemList.size()) return const_cast<MessageItem *>(&msgItemList[i]); - Q_ASSERT(i >= 0 && i < msgItemList.count()); + Q_ASSERT(i >= 0 && i < msgItemList.size()); return 0; } @@ -101,14 +101,14 @@ DataModel::DataModel(QObject *parent) QStringList DataModel::normalizedTranslations(const MessageItem &m) const { - return Translator::normalizedTranslations(m.message(), m_numerusForms.count()); + return Translator::normalizedTranslations(m.message(), m_numerusForms.size()); } ContextItem *DataModel::contextItem(int context) const { - if (context >= 0 && context < m_contextList.count()) + if (context >= 0 && context < m_contextList.size()) return const_cast<ContextItem *>(&m_contextList[context]); - Q_ASSERT(context >= 0 && context < m_contextList.count()); + Q_ASSERT(context >= 0 && context < m_contextList.size()); return 0; } @@ -121,7 +121,7 @@ MessageItem *DataModel::messageItem(const DataIndex &index) const ContextItem *DataModel::findContext(const QString &context) const { - for (int c = 0; c < m_contextList.count(); ++c) { + for (int c = 0; c < m_contextList.size(); ++c) { ContextItem *ctx = contextItem(c); if (ctx->context() == context) return ctx; @@ -344,9 +344,9 @@ bool DataModel::release(const QString &fileName, bool verbose, bool ignoreUnfini void DataModel::doCharCounting(const QString &text, int &trW, int &trC, int &trCS) { - trCS += text.length(); + trCS += text.size(); bool inWord = false; - for (int i = 0; i < text.length(); ++i) { + for (int i = 0; i < text.size(); ++i) { if (text[i].isLetterOrNumber() || text[i] == QLatin1Char('_')) { if (!inWord) { ++trW; @@ -456,7 +456,7 @@ QString DataModel::prettifyPlainFileName(const QString &fn) { static QString workdir = QDir::currentPath() + QLatin1Char('/'); - return QDir::toNativeSeparators(fn.startsWith(workdir) ? fn.mid(workdir.length()) : fn); + return QDir::toNativeSeparators(fn.startsWith(workdir) ? fn.mid(workdir.size()) : fn); } QString DataModel::prettifyFileName(const QString &fn) @@ -480,7 +480,7 @@ DataModelIterator::DataModelIterator(DataModel *model, int context, int message) bool DataModelIterator::isValid() const { - return m_context < m_model->m_contextList.count(); + return m_context < m_model->m_contextList.size(); } void DataModelIterator::operator++() @@ -588,9 +588,9 @@ void MultiContextItem::putMessageItem(int pos, MessageItem *m) void MultiContextItem::appendMessageItems(const QList<MessageItem *> &m) { QList<MessageItem *> nullItems = m; // Basically, just a reservation - for (int i = 0; i < nullItems.count(); ++i) + for (int i = 0; i < nullItems.size(); ++i) nullItems[i] = 0; - for (int i = 0; i < m_messageLists.count() - 1; ++i) + for (int i = 0; i < m_messageLists.size() - 1; ++i) m_messageLists[i] += nullItems; m_messageLists.last() += m; for (MessageItem *mi : m) @@ -599,7 +599,7 @@ void MultiContextItem::appendMessageItems(const QList<MessageItem *> &m) void MultiContextItem::removeMultiMessageItem(int pos) { - for (int i = 0; i < m_messageLists.count(); ++i) + for (int i = 0; i < m_messageLists.size(); ++i) m_messageLists[i].removeAt(pos); m_multiMessageList.removeAt(pos); } @@ -782,7 +782,7 @@ void MultiDataModel::append(DataModel *dm, bool readWrite) void MultiDataModel::close(int model) { - if (m_dataModels.count() == 1) { + if (m_dataModels.size() == 1) { closeAll(); } else { updateCountsOnRemove(model, isModelWritable(model)); @@ -854,34 +854,34 @@ QString MultiDataModel::condenseFileNames(const QStringList &names) if (names.isEmpty()) return QString(); - if (names.count() < 2) + if (names.size() < 2) return names.first(); QString prefix = names.first(); if (prefix.startsWith(QLatin1Char('='))) prefix.remove(0, 1); QString suffix = prefix; - for (int i = 1; i < names.count(); ++i) { + for (int i = 1; i < names.size(); ++i) { QString fn = names[i]; if (fn.startsWith(QLatin1Char('='))) fn.remove(0, 1); - for (int j = 0; j < prefix.length(); ++j) + for (int j = 0; j < prefix.size(); ++j) if (fn[j] != prefix[j]) { - if (j < prefix.length()) { + if (j < prefix.size()) { while (j > 0 && prefix[j - 1].isLetterOrNumber()) --j; prefix.truncate(j); } break; } - int fnl = fn.length() - 1; - int sxl = suffix.length() - 1; + int fnl = fn.size() - 1; + int sxl = suffix.size() - 1; for (int k = 0; k <= sxl; ++k) if (fn[fnl - k] != suffix[sxl - k]) { if (k < sxl) { while (k > 0 && suffix[sxl - k + 1].isLetterOrNumber()) --k; - if (prefix.length() + k > fnl) + if (prefix.size() + k > fnl) --k; suffix.remove(0, sxl - k + 1); } @@ -889,9 +889,9 @@ QString MultiDataModel::condenseFileNames(const QStringList &names) } } QString ret = prefix + QLatin1Char('{'); - int pxl = prefix.length(); - int sxl = suffix.length(); - for (int j = 0; j < names.count(); ++j) { + int pxl = prefix.size(); + int sxl = suffix.size(); + for (int j = 0; j < names.size(); ++j) { if (j) ret += QLatin1Char(','); int off = pxl; @@ -900,7 +900,7 @@ QString MultiDataModel::condenseFileNames(const QStringList &names) ret += QLatin1Char('='); ++off; } - ret += fn.mid(off, fn.length() - sxl - off); + ret += fn.mid(off, fn.size() - sxl - off); } ret += QLatin1Char('}') + suffix; return ret; @@ -1168,7 +1168,7 @@ void MultiDataModelIterator::operator++() bool MultiDataModelIterator::isValid() const { - return m_context < m_dataModel->m_multiContextList.count(); + return m_context < m_dataModel->m_multiContextList.size(); } MessageItem *MultiDataModelIterator::current() const diff --git a/src/linguist/linguist/messagemodel.h b/src/linguist/linguist/messagemodel.h index 2269f49ce..0dc5f0777 100644 --- a/src/linguist/linguist/messagemodel.h +++ b/src/linguist/linguist/messagemodel.h @@ -84,7 +84,7 @@ public: bool isFinished() const { return unfinishedCount() == 0; } MessageItem *messageItem(int i) const; - int messageCount() const { return msgItemList.count(); } + int messageCount() const { return msgItemList.size(); } MessageItem *findMessage(const QString &sourcetext, const QString &comment) const; @@ -147,7 +147,7 @@ public: enum FindLocation { NoLocation = 0, SourceText = 0x1, Translations = 0x2, Comments = 0x4 }; // Specializations - int contextCount() const { return m_contextList.count(); } + int contextCount() const { return m_contextList.size(); } ContextItem *findContext(const QString &context) const; MessageItem *findMessage(const QString &context, const QString &sourcetext, const QString &comment) const; @@ -284,7 +284,7 @@ public: QString context() const { return m_context; } QString comment() const { return m_comment; } - int messageCount() const { return m_messageLists.isEmpty() ? 0 : m_messageLists[0].count(); } + int messageCount() const { return m_messageLists.isEmpty() ? 0 : m_messageLists[0].size(); } // For item count in context list int getNumFinished() const { return m_finishedCount; } int getNumEditable() const { return m_editableCount; } @@ -377,8 +377,8 @@ public: void moveModel(int oldPos, int newPos); // newPos is *before* removing at oldPos; note that this does not emit update signals // Entire multi-model - int modelCount() const { return m_dataModels.count(); } - int contextCount() const { return m_multiContextList.count(); } + int modelCount() const { return m_dataModels.size(); } + int contextCount() const { return m_multiContextList.size(); } int messageCount() const { return m_numMessages; } // Next two needed for progress indicator in main window int getNumFinished() const { return m_numFinished; } diff --git a/src/linguist/linguist/phrasemodel.cpp b/src/linguist/linguist/phrasemodel.cpp index 956bffb83..60e1256d7 100644 --- a/src/linguist/linguist/phrasemodel.cpp +++ b/src/linguist/linguist/phrasemodel.cpp @@ -7,7 +7,7 @@ QT_BEGIN_NAMESPACE void PhraseModel::removePhrases() { - int r = plist.count(); + int r = plist.size(); if (r > 0) { beginResetModel(); plist.clear(); @@ -34,7 +34,7 @@ void PhraseModel::setPhrase(const QModelIndex &indx, Phrase *ph) QModelIndex PhraseModel::addPhrase(Phrase *p) { - int r = plist.count(); + int r = plist.size(); plist.append(p); @@ -64,7 +64,7 @@ QModelIndex PhraseModel::index(Phrase * const phr) const int PhraseModel::rowCount(const QModelIndex &) const { - return plist.count(); + return plist.size(); } int PhraseModel::columnCount(const QModelIndex &) const @@ -105,7 +105,7 @@ bool PhraseModel::setData(const QModelIndex & index, const QVariant & value, int int row = index.row(); int column = index.column(); - if (!index.isValid() || row >= plist.count() || role != Qt::EditRole) + if (!index.isValid() || row >= plist.size() || role != Qt::EditRole) return false; Phrase *phrase = plist.at(row); @@ -133,7 +133,7 @@ QVariant PhraseModel::data(const QModelIndex &index, int role) const int row = index.row(); int column = index.column(); - if (row >= plist.count() || !index.isValid()) + if (row >= plist.size() || !index.isValid()) return QVariant(); Phrase *phrase = plist.at(row); diff --git a/src/linguist/linguist/printout.cpp b/src/linguist/linguist/printout.cpp index bd142ce70..e1a096ccc 100644 --- a/src/linguist/linguist/printout.cpp +++ b/src/linguist/linguist/printout.cpp @@ -61,7 +61,7 @@ void PrintOut::flushLine(bool /* mayBreak */) else if (!firstParagraph) drawRule(nextRule); - for (int i = 0; i < cp.boxes.count(); ++i) { + for (int i = 0; i < cp.boxes.size(); ++i) { Box b = cp.boxes[i]; b.rect.translate(0, voffset); QRect r = b.rect; diff --git a/src/linguist/linguist/recentfiles.cpp b/src/linguist/linguist/recentfiles.cpp index b35d5edc1..cd6088a58 100644 --- a/src/linguist/linguist/recentfiles.cpp +++ b/src/linguist/linguist/recentfiles.cpp @@ -71,7 +71,7 @@ void RecentFiles::addFiles(const QStringList &names) m_strLists.removeAt(index); m_clone1st = true; } else { - if (m_strLists.count() >= m_maxEntries) + if (m_strLists.size() >= m_maxEntries) m_strLists.removeLast(); m_clone1st = false; } diff --git a/src/linguist/lrelease/main.cpp b/src/linguist/lrelease/main.cpp index ed0dbef50..b4b5d11dc 100644 --- a/src/linguist/lrelease/main.cpp +++ b/src/linguist/lrelease/main.cpp @@ -132,7 +132,7 @@ static bool releaseTsFile(const QString& tsFileName, QString qmFileName = tsFileName; for (const Translator::FileFormat &fmt : qAsConst(Translator::registeredFileFormats())) { if (qmFileName.endsWith(QLatin1Char('.') + fmt.extension)) { - qmFileName.chop(fmt.extension.length() + 1); + qmFileName.chop(fmt.extension.size() + 1); break; } } diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index 35fbd294b..0526b4c0e 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -926,7 +926,7 @@ QString CppParser::stringifyNamespace(int start, const NamespaceList &namespaces QString ret; int l = 0; for (int j = start; j < namespaces.count(); ++j) - l += namespaces.at(j).value().length(); + l += namespaces.at(j).value().size(); ret.reserve(l + qMax(0, (namespaces.count() - start - 1)) * 2); for (int i = start; i < namespaces.count(); ++i) { if (i > start) @@ -1012,7 +1012,7 @@ bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) cons for (const HashStringList &use : ns->usings) if (!data->visitedUsings->contains(use)) { data->visitedUsings->insert(use); - if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved, + if (qualifyOne(use.value(), use.value().size(), data->segment, data->resolved, data->visitedUsings)) return true; } @@ -1657,7 +1657,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac // so they don't confuse our scoping of static initializers. // we enter the loop by either reading a left bracket or by an // #else popping the state. - if (yyBracketDepth && yyBraceDepth == namespaceDepths.count()) { + if (yyBracketDepth && yyBraceDepth == namespaceDepths.size()) { yyTok = getToken(); continue; } @@ -1703,7 +1703,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac Partial support for inlined functions. */ yyTok = getToken(); - if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) { + if (yyBraceDepth == namespaceDepths.size() && yyParenDepth == 0) { NamespaceList quali; HashString fct; @@ -1880,7 +1880,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac break; case Tok_Ident: if (yyTokColonSeen && - yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) { + yyBraceDepth == namespaceDepths.size() && yyParenDepth == 0) { // member or base class identifier yyTokIdentSeen = true; } @@ -1954,7 +1954,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac yyTok = getToken(); break; } - if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0 && !yyTokColonSeen) + if (yyBraceDepth == namespaceDepths.size() && yyParenDepth == 0 && !yyTokColonSeen) prospectiveContext = prefix; prefix += strColons; yyTok = getToken(); @@ -1967,11 +1967,11 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac break; case Tok_RightBrace: if (!yyTokColonSeen) { - if (yyBraceDepth + 1 == namespaceDepths.count()) { + if (yyBraceDepth + 1 == namespaceDepths.size()) { // class or namespace truncateNamespaces(&namespaces, namespaceDepths.pop()); } - if (yyBraceDepth == namespaceDepths.count()) { + if (yyBraceDepth == namespaceDepths.size()) { // function, class or namespace if (!yyBraceDepth && !directInclude) truncateNamespaces(&functionContext, 1); @@ -2006,7 +2006,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac break; case Tok_Colon: case Tok_Equals: - if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) { + if (yyBraceDepth == namespaceDepths.size() && yyParenDepth == 0) { if (!prospectiveContext.isEmpty()) { pendingContext = prospectiveContext; prospectiveContext.clear(); @@ -2021,7 +2021,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac yyTok = getToken(); break; case Tok_LeftBrace: - if (yyBraceDepth == namespaceDepths.count() + 1 && yyParenDepth == 0) { + if (yyBraceDepth == namespaceDepths.size() + 1 && yyParenDepth == 0) { if (!prospectiveContext.isEmpty()) { pendingContext = prospectiveContext; prospectiveContext.clear(); @@ -2036,7 +2036,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac yyTok = getToken(); break; case Tok_LeftParen: - if (!yyTokColonSeen && yyBraceDepth == namespaceDepths.count() && yyParenDepth == 1 + if (!yyTokColonSeen && yyBraceDepth == namespaceDepths.size() && yyParenDepth == 1 && !prospectiveContext.isEmpty()) { pendingContext = prospectiveContext; prospectiveContext.clear(); @@ -2053,7 +2053,7 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac case Tok_RightParen: if (yyParenDepth == 0) { if (!yyTokColonSeen && !pendingContext.isEmpty() - && yyBraceDepth == namespaceDepths.count()) { + && yyBraceDepth == namespaceDepths.size()) { // Demote the pendingContext to prospectiveContext. prospectiveContext = pendingContext; pendingContext.clear(); @@ -2111,11 +2111,11 @@ void CppParser::processComment() extra.insert(text.left(k), text.mid(k + 1).trimmed()); text.clear(); } else if (*ptr == QLatin1Char('%') && ptr[1].isSpace()) { - sourcetext.reserve(sourcetext.length() + yyWord.length() - 2); - ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); + sourcetext.reserve(sourcetext.size() + yyWord.size() - 2); + ushort *ptr = (ushort *)sourcetext.data() + sourcetext.size(); int p = 2, c; forever { - if (p >= yyWord.length()) + if (p >= yyWord.size()) break; c = yyWord.unicode()[p++].unicode(); if (isspace(c)) @@ -2125,7 +2125,7 @@ void CppParser::processComment() break; } forever { - if (p >= yyWord.length()) { + if (p >= yyWord.size()) { whoops: yyMsg() << "Unterminated meta string\n"; break; @@ -2134,7 +2134,7 @@ void CppParser::processComment() if (c == '"') break; if (c == '\\') { - if (p >= yyWord.length()) + if (p >= yyWord.size()) goto whoops; c = yyWord.unicode()[p++].unicode(); if (c == '\n') @@ -2151,10 +2151,10 @@ void CppParser::processComment() ushort c; while ((c = uc[idx]) == ' ' || c == '\t' || c == '\n') ++idx; - if (!memcmp(uc + idx, MagicComment.unicode(), MagicComment.length() * 2)) { - idx += MagicComment.length(); + if (!memcmp(uc + idx, MagicComment.unicode(), MagicComment.size() * 2)) { + idx += MagicComment.size(); comment = QString::fromRawData(yyWord.unicode() + idx, - yyWord.length() - idx).simplified(); + yyWord.size() - idx).simplified(); int k = comment.indexOf(QLatin1Char(' ')); if (k == -1) { context = comment; @@ -2188,7 +2188,7 @@ const ParseResults *CppParser::recordResults(bool isHeader) } if (isHeader) { const ParseResults *pr; - if (!tor && results->includes.count() == 1 + if (!tor && results->includes.size() == 1 && results->rootNamespace.children.isEmpty() && results->rootNamespace.aliases.isEmpty() && results->rootNamespace.usings.isEmpty()) { diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index 09794c8f5..b4dfff6a4 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -144,11 +144,11 @@ QString ParserTool::transcode(const QString &str) const QByteArray in = str.toUtf8(); QByteArray out; - out.reserve(in.length()); - for (int i = 0; i < in.length();) { + out.reserve(in.size()); + for (int i = 0; i < in.size();) { uchar c = in[i++]; if (c == '\\') { - if (i >= in.length()) + if (i >= in.size()) break; c = in[i++]; @@ -158,7 +158,7 @@ QString ParserTool::transcode(const QString &str) if (c == 'x' || c == 'u' || c == 'U') { const bool unicode = (c != 'x'); QByteArray hex; - while (i < in.length() && isxdigit((c = in[i]))) { + while (i < in.size() && isxdigit((c = in[i]))) { hex += c; i++; } @@ -170,7 +170,7 @@ QString ParserTool::transcode(const QString &str) QByteArray oct; int n = 0; oct += c; - while (n < 2 && i < in.length() && (c = in[i]) >= '0' && c < '8') { + while (n < 2 && i < in.size() && (c = in[i]) >= '0' && c < '8') { i++; n++; oct += c; @@ -184,7 +184,7 @@ QString ParserTool::transcode(const QString &str) out += c; } } - return QString::fromUtf8(out.constData(), out.length()); + return QString::fromUtf8(out.constData(), out.size()); } static QString m_defaultExtensions; @@ -580,7 +580,7 @@ static QSet<QString> projectRoots(const QString &projectFile, const QStringList sourceDirs.insert(sf.left(sf.lastIndexOf(QLatin1Char('/')) + 1)); QStringList rootList = sourceDirs.values(); rootList.sort(); - for (int prev = 0, curr = 1; curr < rootList.length(); ) + for (int prev = 0, curr = 1; curr < rootList.size(); ) if (rootList.at(curr).startsWith(rootList.at(prev))) rootList.removeAt(curr); else @@ -883,7 +883,7 @@ int main(int argc, char **argv) outDir = QDir::cleanPath(QFileInfo(args[i]).absoluteFilePath()); continue; } else if (arg.startsWith(QLatin1String("-I"))) { - if (arg.length() == 2) { + if (arg.size() == 2) { ++i; if (i == argc) { printErr(u"The -I option should be followed by a path.\n"_s); @@ -931,7 +931,7 @@ int main(int argc, char **argv) QString lineContent = QString::fromLocal8Bit(lstFile.readLine().trimmed()); if (lineContent.startsWith(QLatin1String("-I"))) { - if (lineContent.length() == 2) { + if (lineContent.size() == 2) { printErr(u"The -I option should be followed by a path.\n"_s); return 1; } @@ -996,7 +996,7 @@ int main(int argc, char **argv) filters |= QDir::AllDirs | QDir::NoDotAndDotDot; QFileInfoList fileinfolist; recursiveFileInfoList(dir, extensionsNameFilters, filters, &fileinfolist); - int scanRootLen = dir.absolutePath().length(); + int scanRootLen = dir.absolutePath().size(); for (const QFileInfo &fi : qAsConst(fileinfolist)) { QString fn = QDir::cleanPath(fi.absoluteFilePath()); if (fn.endsWith(QLatin1String(".qrc"), Qt::CaseInsensitive)) { @@ -1038,7 +1038,7 @@ int main(int argc, char **argv) return 1; } - if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) + if (!targetLanguage.isEmpty() && tsFileNames.size() != 1) printErr(u"lupdate warning: -target-language usually only" " makes sense with exactly one TS file.\n"_s); diff --git a/src/linguist/lupdate/merge.cpp b/src/linguist/lupdate/merge.cpp index f43559cfb..910aa1845 100644 --- a/src/linguist/lupdate/merge.cpp +++ b/src/linguist/lupdate/merge.cpp @@ -103,7 +103,7 @@ static QString translationAttempt(const QString &oldTranslation, number is met, it is replaced with its newNumber equivalent. In our example, the "3.0" of "XeT 3.0" becomes "3.1". */ - for (i = 0; i < oldTranslation.length(); i++) { + for (i = 0; i < oldTranslation.size(); i++) { attempt += oldTranslation[i]; for (k = 0; k < p; k++) { if (oldTranslation[i] == oldNumbers[k][matchedYet[k]]) @@ -123,7 +123,7 @@ static QString translationAttempt(const QString &oldTranslation, best = p; // an impossible value for (k = 0; k < p; k++) { if ((!met[k] || pass > 0) && - matchedYet[k] == oldNumbers[k].length() && + matchedYet[k] == oldNumbers[k].size() && numberLength(oldTranslation, i + 1 - matchedYet[k]) == matchedYet[k]) { // the longer the better if (best == p || matchedYet[k] > matchedYet[best]) @@ -131,7 +131,7 @@ static QString translationAttempt(const QString &oldTranslation, } } if (best != p) { - attempt.truncate(attempt.length() - matchedYet[best]); + attempt.truncate(attempt.size() - matchedYet[best]); attempt += newNumbers[best]; met[best] = true; for (k = 0; k < p; k++) @@ -193,7 +193,7 @@ int applyNumberHeuristic(Translator &tor) if (msg.type() == TranslatorMessage::Unfinished) { if (!hasTranslation) untranslated[i] = true; - } else if (hasTranslation && msg.translations().count() == 1) { + } else if (hasTranslation && msg.translations().size() == 1) { const QString &key = zeroKey(msg.sourceText()); if (!key.isEmpty()) translated.insert(key, qMakePair(msg.sourceText(), msg.translation())); diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp index f787f004b..a99f7dff6 100644 --- a/src/linguist/lupdate/qdeclarative.cpp +++ b/src/linguist/lupdate/qdeclarative.cpp @@ -263,7 +263,7 @@ QString createErrorString(const QString &filename, const QString &code, Parser & const QString textLine = lines.at(line > 0 ? line - 1 : 0); error += textLine + QLatin1Char('\n'); - for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.length()); i < end; ++i) { + for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.size()); i < end; ++i) { const QChar ch = textLine.at(i); if (ch.isSpace()) error += ch; @@ -315,7 +315,7 @@ void FindTrCalls::processComment(const SourceLocation &loc) const QStringView commentStr = engine->midRef(loc.begin(), loc.length); const QChar *chars = commentStr.constData(); - const int length = commentStr.length(); + const int length = commentStr.size(); // Try to match the logic of the C++ parser. if (*chars == QLatin1Char(':') && chars[1].isSpace()) { @@ -330,8 +330,8 @@ void FindTrCalls::processComment(const SourceLocation &loc) if (k > -1) extra.insert(text.left(k), text.mid(k + 1).trimmed()); } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) { - sourcetext.reserve(sourcetext.length() + length-2); - ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); + sourcetext.reserve(sourcetext.size() + length-2); + ushort *ptr = (ushort *)sourcetext.data() + sourcetext.size(); int p = 2, c; forever { if (p >= length) @@ -369,8 +369,8 @@ void FindTrCalls::processComment(const SourceLocation &loc) ushort c; while ((c = chars[idx].unicode()) == ' ' || c == '\t' || c == '\r' || c == '\n') ++idx; - if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.length() * 2)) { - idx += MagicComment.length(); + if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.size() * 2)) { + idx += MagicComment.size(); QString comment = QString(chars + idx, length - idx).simplified(); int k = comment.indexOf(QLatin1Char(' ')); if (k == -1) { diff --git a/src/linguist/shared/ioutils.cpp b/src/linguist/shared/ioutils.cpp index 5a5c45526..71bf0020c 100644 --- a/src/linguist/shared/ioutils.cpp +++ b/src/linguist/shared/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/src/linguist/shared/po.cpp b/src/linguist/shared/po.cpp index a3c47d7c0..ba69e017c 100644 --- a/src/linguist/shared/po.cpp +++ b/src/linguist/shared/po.cpp @@ -27,7 +27,7 @@ static QString poEscapedString(const QString &prefix, const QString &keyword, QStringList lines; int off = 0; QString res; - while (off < ba.length()) { + while (off < ba.size()) { ushort c = ba[off++].unicode(); switch (c) { case '\n': @@ -63,7 +63,7 @@ static QString poEscapedString(const QString &prefix, const QString &keyword, if (c < 32) { res += QLatin1String("\\x"); res += QString::number(c, 16); - if (off < ba.length() && isxdigit(ba[off].unicode())) + if (off < ba.size() && isxdigit(ba[off].unicode())) res += QLatin1String("\"\""); } else { res += QChar(c); @@ -75,15 +75,15 @@ static QString poEscapedString(const QString &prefix, const QString &keyword, lines.append(res); if (!lines.isEmpty()) { if (!noWrap) { - if (lines.count() != 1 || - lines.first().length() > MAX_LEN - keyword.length() - prefix.length() - 3) + if (lines.size() != 1 || + lines.first().size() > MAX_LEN - keyword.size() - prefix.size() - 3) { const QStringList olines = lines; lines = QStringList(QString()); - const int maxlen = MAX_LEN - prefix.length() - 2; + const int maxlen = MAX_LEN - prefix.size() - 2; for (const QString &line : olines) { int off = 0; - while (off + maxlen < line.length()) { + while (off + maxlen < line.size()) { int idx = line.lastIndexOf(QLatin1Char(' '), off + maxlen - 1) + 1; if (idx == off) { #ifdef HARD_WRAP_LONG_WORDS @@ -101,7 +101,7 @@ static QString poEscapedString(const QString &prefix, const QString &keyword, lines.append(line.mid(off)); } } - } else if (lines.count() > 1) { + } else if (lines.size() > 1) { lines.prepend(QString()); } } @@ -133,10 +133,10 @@ static QString poEscapedLines(const QString &prefix, bool addSpace, const QStrin static QString poWrappedEscapedLines(const QString &prefix, bool addSpace, const QString &line) { - const int maxlen = MAX_LEN - prefix.length() - addSpace; + const int maxlen = MAX_LEN - prefix.size() - addSpace; QStringList lines; int off = 0; - while (off + maxlen < line.length()) { + while (off + maxlen < line.size()) { int idx = line.lastIndexOf(QLatin1Char(' '), off + maxlen - 1); if (idx < off) { #if 0 //def HARD_WRAP_LONG_WORDS @@ -202,11 +202,11 @@ static QByteArray slurpEscapedString(const QList<QByteArray> &lines, int &l, break; offset++; forever { - if (offset == line.length()) + if (offset == line.size()) goto premature_eol; uchar c = line[offset++]; if (c == '"') { - if (offset == line.length()) + if (offset == line.size()) break; while (isspace(line[offset])) offset++; @@ -219,7 +219,7 @@ static QByteArray slurpEscapedString(const QList<QByteArray> &lines, int &l, continue; } if (c == '\\') { - if (offset == line.length()) + if (offset == line.size()) goto premature_eol; c = line[offset++]; switch (c) { @@ -260,14 +260,14 @@ static QByteArray slurpEscapedString(const QList<QByteArray> &lines, int &l, case '7': stoff = offset - 1; while ((c = line[offset]) >= '0' && c <= '7') - if (++offset == line.length()) + if (++offset == line.size()) goto premature_eol; msg += line.mid(stoff, offset - stoff).toUInt(0, 8); break; case 'x': stoff = offset; while (isxdigit(line[offset])) - if (++offset == line.length()) + if (++offset == line.size()) goto premature_eol; msg += line.mid(stoff, offset - stoff).toUInt(0, 16); break; @@ -410,7 +410,7 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) bool isObsolete = line.startsWith("#~ msgstr"); const QByteArray prefix = isObsolete ? "#~ " : ""; while (true) { - int idx = line.indexOf(' ', prefix.length()); + int idx = line.indexOf(' ', prefix.size()); QByteArray str = slurpEscapedString(lines, l, idx, prefix, cd); item.msgStr.append(str); if (l + 1 >= lines.size() || !isTranslationLine(lines.at(l + 1))) @@ -491,7 +491,7 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) "Plural-Forms", "X-Language", "X-Source-Language", "X-Qt-Contexts" }; uint cdh = 0; - for (int cho = 0; cho < hdrOrder.length(); cho++) { + for (int cho = 0; cho < hdrOrder.size(); cho++) { for (;; cdh++) { if (cdh == sizeof(dfltHdrs)/sizeof(dfltHdrs[0])) { extras[QLatin1String("po-headers")] = @@ -795,7 +795,7 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &) // This is fuzzy logic, as we don't know whether the string is // actually used with QString::arg(). for (int off = 0; (off = source.indexOf(QLatin1Char('%'), off)) >= 0; ) { - if (++off >= source.length()) + if (++off >= source.size()) break; if (source.at(off) == QLatin1Char('n') || source.at(off).isDigit()) { flags.append(QLatin1String("qt-format")); diff --git a/src/linguist/shared/profileevaluator.cpp b/src/linguist/shared/profileevaluator.cpp index c32aa3dd5..a22a45672 100644 --- a/src/linguist/shared/profileevaluator.cpp +++ b/src/linguist/shared/profileevaluator.cpp @@ -127,7 +127,7 @@ QStringList ProFileEvaluator::absoluteFileValues( // because no sane project would add generated files by wildcard. if (IoUtils::fileType(absDir) == IoUtils::FileIsDir) { QString wildcard = d->m_tmp2.setRawData(absEl.constData() + nameOff + 1, - absEl.length() - nameOff - 1); + absEl.size() - nameOff - 1); if (wildcard.contains(QLatin1Char('*')) || wildcard.contains(QLatin1Char('?'))) { QDir theDir(absDir); for (const QString &fn : theDir.entryList(QStringList(wildcard))) @@ -144,7 +144,7 @@ QStringList ProFileEvaluator::absoluteFileValues( ProFileEvaluator::TemplateType ProFileEvaluator::templateType() const { const ProStringList &templ = d->values(ProKey("TEMPLATE")); - if (templ.count() >= 1) { + if (templ.size() >= 1) { const QString &t = templ.at(0).toQString(); if (!t.compare(QLatin1String("app"), Qt::CaseInsensitive)) return TT_Application; diff --git a/src/linguist/shared/proitems.cpp b/src/linguist/shared/proitems.cpp index 1843f693d..56d2e96d1 100644 --- a/src/linguist/shared/proitems.cpp +++ b/src/linguist/shared/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/src/linguist/shared/qm.cpp b/src/linguist/shared/qm.cpp index 37075294d..33094005a 100644 --- a/src/linguist/shared/qm.cpp +++ b/src/linguist/shared/qm.cpp @@ -196,7 +196,7 @@ Prefix Releaser::commonPrefix(const ByteTranslatorMessage &m1, const ByteTransla void Releaser::writeMessage(const ByteTranslatorMessage &msg, QDataStream &stream, TranslatorSaveMode mode, Prefix prefix) const { - for (int i = 0; i < msg.translations().count(); ++i) + for (int i = 0; i < msg.translations().size(); ++i) stream << quint8(Tag_Translation) << msg.translations().at(i); if (mode == SaveEverything) @@ -357,7 +357,7 @@ void Releaser::squeeze(TranslatorSaveMode mode) do { const char *con = entry.value().constData(); - uint len = uint(entry.value().length()); + uint len = uint(entry.value().size()); len = qMin(len, 255u); t << quint8(len); t.writeRawData(con, len); @@ -503,7 +503,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) QStringList numerusForms; bool guessPlurals = true; if (getNumerusInfo(l, c, 0, &numerusForms, 0)) - guessPlurals = (numerusForms.count() == 1); + guessPlurals = (numerusForms.size() == 1); QString context, sourcetext, comment; QStringList translations; @@ -534,7 +534,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) if (len != -1) str = QString((const QChar *)m, len / 2); if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { - for (int i = 0; i < str.length(); ++i) + for (int i = 0; i < str.size(); ++i) str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00)); } @@ -581,7 +581,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) end:; TranslatorMessage msg; msg.setType(TranslatorMessage::Finished); - if (translations.count() > 1) { + if (translations.size() > 1) { // If guessPlurals is not false here, plural form discard messages // will be spewn out later. msg.setPlural(true); diff --git a/src/linguist/shared/qmakebuiltins.cpp b/src/linguist/shared/qmakebuiltins.cpp index df7236f10..de4514e66 100644 --- a/src/linguist/shared/qmakebuiltins.cpp +++ b/src/linguist/shared/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) { @@ -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/src/linguist/shared/qmakeevaluator.cpp b/src/linguist/shared/qmakeevaluator.cpp index 2e4a3e27d..444260101 100644 --- a/src/linguist/shared/qmakeevaluator.cpp +++ b/src/linguist/shared/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/src/linguist/shared/qmakeglobals.cpp b/src/linguist/shared/qmakeglobals.cpp index 34c443b50..91e7c3bb9 100644 --- a/src/linguist/shared/qmakeglobals.cpp +++ b/src/linguist/shared/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/src/linguist/shared/qmakeparser.cpp b/src/linguist/shared/qmakeparser.cpp index 98540c93d..6ef2bae11 100644 --- a/src/linguist/shared/qmakeparser.cpp +++ b/src/linguist/shared/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; } diff --git a/src/linguist/shared/qph.cpp b/src/linguist/shared/qph.cpp index 708a5e4ab..6a4dd2a6c 100644 --- a/src/linguist/shared/qph.cpp +++ b/src/linguist/shared/qph.cpp @@ -89,7 +89,7 @@ static bool loadQPH(Translator &translator, QIODevice &dev, ConversionData &) static QString protect(const QString &str) { QString result; - result.reserve(str.length() * 12 / 10); + result.reserve(str.size() * 12 / 10); for (int i = 0; i != str.size(); ++i) { uint c = str.at(i).unicode(); switch (c) { diff --git a/src/linguist/shared/qrcreader.cpp b/src/linguist/shared/qrcreader.cpp index bedc06e87..e63ade76a 100644 --- a/src/linguist/shared/qrcreader.cpp +++ b/src/linguist/shared/qrcreader.cpp @@ -31,13 +31,13 @@ ReadQrcResult readQrcFile(const QString &resourceFile, const QString &content) QXmlStreamReader::TokenType t = reader.readNext(); switch (t) { case QXmlStreamReader::StartElement: - if (curDepth >= tagStack.count() || reader.name() != tagStack.at(curDepth)) { + if (curDepth >= tagStack.size() || reader.name() != tagStack.at(curDepth)) { result.errorString = FMT::tr("unexpected <%1> tag\n") .arg(reader.name().toString()); result.line = reader.lineNumber(); return result; } - if (++curDepth == tagStack.count()) + if (++curDepth == tagStack.size()) isFileTag = true; break; diff --git a/src/linguist/shared/simtexth.cpp b/src/linguist/shared/simtexth.cpp index c53daea4c..7d978f475 100644 --- a/src/linguist/shared/simtexth.cpp +++ b/src/linguist/shared/simtexth.cpp @@ -146,7 +146,7 @@ static inline CoMatrix intersection(const CoMatrix &m, const CoMatrix &n) StringSimilarityMatcher::StringSimilarityMatcher(const QString &stringToMatch) : m_cm(stringToMatch) { - m_length = stringToMatch.length(); + m_length = stringToMatch.size(); } int StringSimilarityMatcher::getSimilarityScore(const QString &strCandidate) diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp index 6ac1aa08e..18325c61e 100644 --- a/src/linguist/shared/translator.cpp +++ b/src/linguist/shared/translator.cpp @@ -99,7 +99,7 @@ void Translator::replaceSorted(const TranslatorMessage &msg) static QString elidedId(const QString &id, int len) { - return id.length() <= len ? id : id.left(len - 5) + QLatin1String("[...]"); + return id.size() <= len ? id : id.left(len - 5) + QLatin1String("[...]"); } static QString makeMsgId(const TranslatorMessage &msg) @@ -454,7 +454,7 @@ void Translator::stripIdenticalSourceTranslations() { for (auto it = m_messages.begin(); it != m_messages.end(); ) { // we need to have just one translation, and it be equal to the source - if (it->translations().count() == 1 && it->translation() == it->sourceText()) + if (it->translations().size() == 1 && it->translation() == it->sourceText()) it = m_messages.erase(it); else ++it; @@ -657,11 +657,11 @@ QStringList Translator::normalizedTranslations(const TranslatorMessage &msg, int // make sure that the stringlist always have the size of the // language's current numerus, or 1 if its not plural - if (translations.count() > numTranslations) { - for (int i = translations.count(); i > numTranslations; --i) + if (translations.size() > numTranslations) { + for (int i = translations.size(); i > numTranslations; --i) translations.removeLast(); - } else if (translations.count() < numTranslations) { - for (int i = translations.count(); i < numTranslations; ++i) + } else if (translations.size() < numTranslations) { + for (int i = translations.size(); i < numTranslations; ++i) translations.append(QString()); } return translations; @@ -677,16 +677,16 @@ void Translator::normalizeTranslations(ConversionData &cd) if (l != QLocale::C) { QStringList forms; if (getNumerusInfo(l, c, 0, &forms, 0)) - numPlurals = forms.count(); // includes singular + numPlurals = forms.size(); // includes singular } for (int i = 0; i < m_messages.count(); ++i) { const TranslatorMessage &msg = m_messages.at(i); QStringList tlns = msg.translations(); int ccnt = msg.isPlural() ? numPlurals : 1; - if (tlns.count() != ccnt) { - while (tlns.count() < ccnt) + if (tlns.size() != ccnt) { + while (tlns.size() < ccnt) tlns.append(QString()); - while (tlns.count() > ccnt) { + while (tlns.size() > ccnt) { tlns.removeLast(); truncated = true; } diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp index 9f213498d..0040daf23 100644 --- a/src/linguist/shared/ts.cpp +++ b/src/linguist/shared/ts.cpp @@ -77,7 +77,7 @@ void TSReader::handleError() case Characters: { QString tok = text().toString(); - if (tok.length() > 30) + if (tok.size() > 30) tok = tok.left(30) + QLatin1String("[...]"); raiseError(QString::fromLatin1("Unexpected characters '%1' %2").arg(tok, loc)); } @@ -415,7 +415,7 @@ static QString numericEntity(int ch) static QString protect(const QString &str) { QString result; - result.reserve(str.length() * 12 / 10); + result.reserve(str.size() * 12 / 10); for (int i = 0; i != str.size(); ++i) { const QChar ch = str[i]; uint c = ch.unicode(); @@ -471,12 +471,12 @@ static void writeVariants(QTextStream &t, const char *indent, const QString &inp t << "\n " << indent << "<lengthvariant>" << protect(input.mid(start, offset - start)) << "</lengthvariant>"; - if (offset == input.length()) + if (offset == input.size()) break; start = offset + 1; offset = input.indexOf(QChar(Translator::BinaryVariantSeparator), start); if (offset < 0) - offset = input.length(); + offset = input.size(); } t << "\n" << indent; } else { @@ -619,7 +619,7 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd) if (msg.isPlural()) { t << ">"; const QStringList &translns = msg.translations(); - for (int j = 0; j < translns.count(); ++j) { + for (int j = 0; j < translns.size(); ++j) { t << "\n <numerusform"; writeVariants(t, " ", translns[j]); t << "</numerusform>"; diff --git a/src/linguist/shared/xliff.cpp b/src/linguist/shared/xliff.cpp index 695164f62..1d0d9e490 100644 --- a/src/linguist/shared/xliff.cpp +++ b/src/linguist/shared/xliff.cpp @@ -224,7 +224,7 @@ static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const oldsources.append(msg.oldSourceText()); if (const auto it = extras.constFind(QString::fromLatin1("po-old_msgid_plural")); it != extrasEnd) { if (oldsources.isEmpty()) { - if (sources.count() == 2) + if (sources.size() == 2) oldsources.append(QString()); else pluralStr = QLatin1Char(' ') + QLatin1String(attribPlural) + QLatin1String("=\"yes\""); @@ -451,7 +451,7 @@ XLIFFHandler::XliffContext XLIFFHandler::currentContext() const // traverses to the top to check all of the parent contexes. bool XLIFFHandler::hasContext(XliffContext ctx) const { - for (int i = m_contextStack.count() - 1; i >= 0; --i) { + for (int i = m_contextStack.size() - 1; i >= 0; --i) { if (m_contextStack.at(i) == ctx) return true; } @@ -684,12 +684,12 @@ bool XLIFFHandler::finalizeMessage(bool isPlural) msg.setOldComment(m_oldComment); msg.setExtraComment(m_extraComment); msg.setTranslatorComment(m_translatorComment); - if (m_sources.count() > 1 && m_sources[1] != m_sources[0]) + if (m_sources.size() > 1 && m_sources[1] != m_sources[0]) m_extra.insert(QLatin1String("po-msgid_plural"), m_sources[1]); if (!m_oldSources.isEmpty()) { if (!m_oldSources[0].isEmpty()) msg.setOldSourceText(m_oldSources[0]); - if (m_oldSources.count() > 1 && m_oldSources[1] != m_oldSources[0]) + if (m_oldSources.size() > 1 && m_oldSources[1] != m_oldSources[0]) m_extra.insert(QLatin1String("po-old_msgid_plural"), m_oldSources[1]); } msg.setExtras(m_extra); |