diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-11-11 15:53:00 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-18 13:59:33 +0100 |
commit | c5f3c61469517a4ac00e4da01fe0bab9188c1488 (patch) | |
tree | f5003575925ea3f88e469380f29454d1f1fbca49 /src/widgets/widgets | |
parent | 4fd2c8fe1d679302391218aec03aa309afd38c55 (diff) | |
download | qtbase-c5f3c61469517a4ac00e4da01fe0bab9188c1488.tar.gz |
Port from container::count() and length() to size() - V5
This is the same semantic patch (qt-port-to-std-compatible-api V5
with config Scope: 'Container') as in dev. I've re-ran it in 6.4 to
avoid cherry-pick conflicts.
Like in dev, added two NOLINTNEXTLINEs in tst_qbitarray and
tst_qcontiguouscache, to avoid porting calls that explicitly test
count().
Change-Id: I9621dee5ed328b47e78919a34c307105e4311903
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets')
29 files changed, 309 insertions, 309 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 122d81e1ed..bac4a29cff 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -180,10 +180,10 @@ QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const Q_Q(const QAbstractButton); QList<QAbstractButton *> buttonList = queryButtonList(); - if (!autoExclusive || buttonList.count() == 1) // no group + if (!autoExclusive || buttonList.size() == 1) // no group return nullptr; - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *b = buttonList.at(i); if (b->d_func()->checked && b != q) return b; @@ -227,7 +227,7 @@ void QAbstractButtonPrivate::moveFocus(int key) QPoint goal = target.center(); uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus; - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *button = buttonList.at(i); if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() && (exclusive || (button->focusPolicy() & focus_flag) == focus_flag)) { @@ -310,7 +310,7 @@ void QAbstractButtonPrivate::fixFocusPolicy() return; QList<QAbstractButton *> buttonList = queryButtonList(); - for (int i = 0; i < buttonList.count(); ++i) { + for (int i = 0; i < buttonList.size(); ++i) { QAbstractButton *b = buttonList.at(i); if (!b->isCheckable()) continue; diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 7fd94e6201..91fedea650 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -368,7 +368,7 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol #if QT_CONFIG(itemviews) if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) { const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>(); - if (headers.count() <= 2) { + if (headers.size() <= 2) { for (const QHeaderView *header : headers) { const QRect geo = header->geometry(); if (header->orientation() == Qt::Vertical && header->isVisible() && QStyle::visualRect(opt.direction, opt.rect, geo).left() <= opt.rect.width() / 2) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index ff41a72fca..c168b3d990 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1952,7 +1952,7 @@ QValidator::State QSpinBoxValidator::validate(QString &input, int &pos) const if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { input.prepend(dptr->prefix); - pos += dptr->prefix.length(); + pos += dptr->prefix.size(); } if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix)) diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index bd0c959396..3a992fed74 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -14,7 +14,7 @@ void QButtonGroupPrivate::detectCheckedButton() checkedButton = nullptr; if (exclusive) return; - for (int i = 0; i < buttonList.count(); i++) { + for (int i = 0; i < buttonList.size(); i++) { if (buttonList.at(i) != previous && buttonList.at(i)->isChecked()) { checkedButton = buttonList.at(i); return; @@ -82,7 +82,7 @@ QButtonGroup::QButtonGroup(QObject *parent) QButtonGroup::~QButtonGroup() { Q_D(QButtonGroup); - for (int i = 0; i < d->buttonList.count(); ++i) + for (int i = 0; i < d->buttonList.size(); ++i) d->buttonList.at(i)->d_func()->group = nullptr; } diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 42ef8c4a35..4d3360226f 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -72,7 +72,7 @@ QString QCalendarDateSectionValidator::highlightString(const QString &str, int p { if (pos == 0) return "<b>"_L1 + str + "</b>"_L1; - int startPos = str.length() - pos; + int startPos = str.size() - pos; return QStringView{str}.mid(0, startPos) + "<b>"_L1 + QStringView{str}.mid(startPos, pos) + "</b>"_L1; } @@ -728,7 +728,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) if (m_widget) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent* ke = (QKeyEvent*)e; - if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { + if ((ke->text().size() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { applyDate(); emit editingFinished(); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 7c5de0e2cb..330bcb6a39 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2298,7 +2298,7 @@ void QComboBox::insertItems(int index, const QStringList &list) if (list.isEmpty()) return; index = qBound(0, index, count()); - int insertCount = qMin(d->maxCount - index, list.count()); + int insertCount = qMin(d->maxCount - index, list.size()); if (insertCount <= 0) return; // For the common case where we are using the built in QStandardItemModel diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 897e0dce06..e7b644a67b 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1830,7 +1830,7 @@ int QDateTimeEditPrivate::sectionAt(int pos) const const int textSize = text.size(); if (textSize - pos < separators.last().size() + 1) { if (separators.last().size() == 0) { - return sectionNodes.count() - 1; + return sectionNodes.size() - 1; } return (pos == textSize ? LastSectionIndex : NoSectionIndex); } diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 8d874aaa03..1f8bdc0f94 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -185,8 +185,8 @@ void QDialogButtonBoxPrivate::resetLayout() void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse) { - int start = reverse ? buttonList.count() - 1 : 0; - int end = reverse ? -1 : buttonList.count(); + int start = reverse ? buttonList.size() - 1 : 0; + int end = reverse ? -1 : buttonList.size(); int step = reverse ? -1 : 1; for (int i = start; i != end; i += step) { @@ -636,7 +636,7 @@ void QDialogButtonBox::clear() d->standardButtonHash.clear(); for (int i = 0; i < NRoles; ++i) { QList<QAbstractButton *> &list = d->buttonLists[i]; - while (list.count()) { + while (list.size()) { QAbstractButton *button = list.takeAt(0); QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed())); delete button; @@ -655,7 +655,7 @@ QList<QAbstractButton *> QDialogButtonBox::buttons() const QList<QAbstractButton *> finalList; for (int i = 0; i < NRoles; ++i) { const QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) + for (int j = 0; j < list.size(); ++j) finalList.append(list.at(j)); } return finalList; @@ -672,7 +672,7 @@ QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *butto Q_D(const QDialogButtonBox); for (int i = 0; i < NRoles; ++i) { const QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) { + for (int j = 0; j < list.size(); ++j) { if (list.at(j) == button) return ButtonRole(i); } @@ -696,7 +696,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) d->standardButtonHash.remove(reinterpret_cast<QPushButton *>(button)); for (int i = 0; i < NRoles; ++i) { QList<QAbstractButton *> &list = d->buttonLists[i]; - for (int j = 0; j < list.count(); ++j) { + for (int j = 0; j < list.size(); ++j) { if (list.at(j) == button) { list.takeAt(j); if (!d->internalRemove) { diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index cec1d1bc14..91737b301a 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -91,7 +91,7 @@ bool QDockAreaLayoutItem::skip() const return widgetItem->isEmpty(); if (subinfo != nullptr) { - for (int i = 0; i < subinfo->item_list.count(); ++i) { + for (int i = 0; i < subinfo->item_list.size(); ++i) { if (!subinfo->item_list.at(i).skip()) return false; } @@ -852,7 +852,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, delta = growlimit; int d = 0; - for (int i = index + 1; d < delta && i < list.count(); ++i) + for (int i = index + 1; d < delta && i < list.size(); ++i) d += shrink(list[i], delta - d); delta = d; d = 0; @@ -860,7 +860,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, d += grow(list[i], delta - d); } else if (delta < 0) { int growlimit = 0; - for (int i = index + 1; i < list.count(); ++i) { + for (int i = index + 1; i < list.size(); ++i) { const QLayoutStruct &ls = list.at(i); if (ls.empty) continue; @@ -878,7 +878,7 @@ static int separatorMoveHelper(QList<QLayoutStruct> &list, int index, int delta, d += shrink(list[i], -delta - d); delta = -d; d = 0; - for (int i = index + 1; d < -delta && i < list.count(); ++i) + for (int i = index + 1; d < -delta && i < list.size(); ++i) d += grow(list[i], -delta - d); } @@ -949,12 +949,12 @@ void QDockAreaLayoutInfo::unnest(int index) QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == nullptr) return; - if (item.subinfo->item_list.count() > 1) + if (item.subinfo->item_list.size() > 1) return; - if (item.subinfo->item_list.count() == 0) { + if (item.subinfo->item_list.size() == 0) { item_list.removeAt(index); - } else if (item.subinfo->item_list.count() == 1) { + } else if (item.subinfo->item_list.size() == 1) { QDockAreaLayoutItem &child = item.subinfo->item_list.first(); if (child.widgetItem != nullptr) { item.widgetItem = child.widgetItem; @@ -974,7 +974,7 @@ void QDockAreaLayoutInfo::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - if (path.count() > 1) { + if (path.size() > 1) { const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); @@ -994,7 +994,7 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) if (index < 0) index = -index - 1; - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->plug(path.mid(1)); @@ -1013,7 +1013,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->unplug(path.mid(1)); @@ -1103,7 +1103,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); - if (path.count() > 1) { + if (path.size() > 1) { QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == nullptr @@ -1185,7 +1185,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid break; } } else { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -1224,7 +1224,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -1251,9 +1251,9 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) int index = path.first(); if (index < 0) index = -index - 1; - if (index >= item_list.count()) + if (index >= item_list.size()) return this; - if (path.count() == 1 || item_list[index].subinfo == nullptr) + if (path.size() == 1 || item_list[index].subinfo == nullptr) return this; return item_list[index].subinfo->info(path.mid(1)); } @@ -1308,7 +1308,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != nullptr); return item.subinfo->itemRect(path.mid(1)); @@ -1341,7 +1341,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != nullptr); return item.subinfo->separatorRect(path.mid(1)); @@ -1566,7 +1566,7 @@ QRegion QDockAreaLayoutInfo::separatorRegion() const return result; #endif - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -1596,7 +1596,7 @@ void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget, return; #endif - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -1681,7 +1681,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); const int index = path.first(); - if (path.count() > 1) { + if (path.size() > 1) { const QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != nullptr); return item.subinfo->item(path.mid(1)); @@ -1691,7 +1691,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.placeHolderItem != nullptr) continue; @@ -1708,7 +1708,7 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.placeHolderItem != nullptr) continue; @@ -1733,7 +1733,7 @@ QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) void QDockAreaLayoutInfo::deleteAllLayoutItems() { - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item= item_list[i]; if (item.subinfo) { item.subinfo->deleteAllLayoutItems(); @@ -1753,7 +1753,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const // write the index in item_list of the widget that's currently on top. quintptr id = currentTabId(); int index = -1; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (tabId(item_list.at(i)) == id) { index = i; break; @@ -1766,9 +1766,9 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const stream << (uchar) SequenceMarker; } - stream << (uchar) o << int(item_list.count()); + stream << (uchar) o << int(item_list.size()); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.widgetItem != nullptr) { stream << (uchar) WidgetMarker; @@ -1864,7 +1864,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } QDockWidget *widget = nullptr; - for (int j = 0; j < widgets.count(); ++j) { + for (int j = 0; j < widgets.size(); ++j) { if (widgets.at(j)->objectName() == name) { widget = widgets.takeAt(j); break; @@ -1950,7 +1950,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } #if QT_CONFIG(tabbar) - if (!testing && tabbed && index >= 0 && index < item_list.count()) { + if (!testing && tabbed && index >= 0 && index < item_list.size()) { updateTabBar(); setCurrentTabId(tabId(item_list.at(index))); } @@ -1970,7 +1970,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const } int j = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -2022,7 +2022,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) if (tabBar) tabBar->setParent(parent); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.flags & QDockAreaLayoutItem::GapItem) continue; @@ -2062,7 +2062,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const const quintptr oldCurrentId = currentTabId(); int tab_idx = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) continue; @@ -2127,7 +2127,7 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) if (tabBar != nullptr) tabBar->setShape(static_cast<QTabBar::Shape>(shape)); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.subinfo != nullptr) item.subinfo->setTabBarShape(shape); @@ -2159,7 +2159,7 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const result.insert(tabBar); } - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.subinfo != nullptr) result += item.subinfo->usedTabBars(); @@ -2173,13 +2173,13 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const { QSet<QWidget*> result; - const int numSeparatorWidgets = separatorWidgets.count(); + const int numSeparatorWidgets = separatorWidgets.size(); result.reserve(numSeparatorWidgets); for (int i = 0; i < numSeparatorWidgets; ++i) result << separatorWidgets.at(i); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.subinfo != nullptr) result += item.subinfo->usedSeparatorWidgets(); @@ -2226,7 +2226,7 @@ int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const { Q_ASSERT(tabbed && tabBar); quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex)); - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (tabId(item_list.at(i)) == data) return i; } @@ -2490,7 +2490,7 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.count() == 1) + if (path.size() == 1) return &docks[index]; return docks[index].info(path.mid(1)); @@ -2545,7 +2545,7 @@ QRect QDockAreaLayout::separatorRect(const QList<int> &path) const const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.count() == 1) + if (path.size() == 1) return separatorRect(index); else return docks[index].separatorRect(path.mid(1)); @@ -3043,7 +3043,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do { QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget); QDockAreaLayoutInfo &info = docks[pos]; - if (orientation == info.o || info.item_list.count() <= 1) { + if (orientation == info.o || info.item_list.size() <= 1) { // empty dock areas, or dock areas containing exactly one widget can have their orientation // switched. info.o = orientation; @@ -3089,11 +3089,11 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o) { - if (Q_UNLIKELY(docks.count() != sizes.count())) { + if (Q_UNLIKELY(docks.size() != sizes.size())) { qWarning("QMainWidget::resizeDocks: size of the lists are not the same"); return; } - int count = docks.count(); + int count = docks.size(); fallbackToSizeHints = false; for (int i = 0; i < count; ++i) { QList<int> path = indexOf(docks[i]); @@ -3206,7 +3206,7 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or int delta = 0; int index = separator.last(); - if (separator.count() > 1) { + if (separator.size() > 1) { QDockAreaLayoutInfo *info = this->info(separator); delta = pick(info->o, dest - origin); if (delta != 0) @@ -3347,7 +3347,7 @@ QSet<QTabBar*> QDockAreaLayout::usedTabBars() const QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const { QSet<QWidget*> result; - const int numSeparators = separatorWidgets.count(); + const int numSeparators = separatorWidgets.size(); result.reserve(numSeparators); for (int i = 0; i < numSeparators; ++i) result << separatorWidgets.at(i); @@ -3365,7 +3365,7 @@ QRect QDockAreaLayout::gapRect(const QList<int> &path) const if (info == nullptr) return QRect(); int index = path.last(); - if (index < 0 || index >= info->item_list.count()) + if (index < 0 || index >= info->item_list.size()) return QRect(); return info->itemRect(index, true); } diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 2b253ce2b7..67bb099446 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -277,7 +277,7 @@ void QDockWidgetLayout::addItem(QLayoutItem*) QLayoutItem *QDockWidgetLayout::itemAt(int index) const { int cnt = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QLayoutItem *item = item_list.at(i); if (item == nullptr) continue; @@ -290,7 +290,7 @@ QLayoutItem *QDockWidgetLayout::itemAt(int index) const QLayoutItem *QDockWidgetLayout::takeAt(int index) { int j = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { QLayoutItem *item = item_list.at(i); if (item == nullptr) continue; @@ -307,7 +307,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) int QDockWidgetLayout::count() const { int result = 0; - for (int i = 0; i < item_list.count(); ++i) { + for (int i = 0; i < item_list.size(); ++i) { if (item_list.at(i)) ++result; } @@ -1577,7 +1577,7 @@ bool QDockWidget::event(QEvent *event) bool onTop = false; if (win != nullptr) { const QObjectList &siblings = win->children(); - onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; + onTop = siblings.size() > 0 && siblings.last() == (QObject*)this; } #if QT_CONFIG(tabbar) if (!isFloating() && layout != nullptr && onTop) diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index c4239e70ca..a7f31995e1 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -132,13 +132,13 @@ static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool return system; } - if (writingSystems.count() == 1 && system > QFontDatabase::Cyrillic) + if (writingSystems.size() == 1 && system > QFontDatabase::Cyrillic) return system; - if (writingSystems.count() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese) + if (writingSystems.size() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese) return system; - if (writingSystems.count() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean) + if (writingSystems.size() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean) return system; return QFontDatabase::Any; @@ -317,7 +317,7 @@ void QFontComboBoxPrivate::_q_updateModel() } result += list.at(i); if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + " ["_L1)) - offset = result.count() - 1; + offset = result.size() - 1; } list = result; diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 6f49b831ad..eef2685569 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -149,7 +149,7 @@ static QString int2string(int num, int base, int ndigits, bool *oflow) break; } if (negative) { - for (int i=0; i<(int)s.length(); i++) { + for (int i=0; i<(int)s.size(); i++) { if (s[i] != u' ') { if (i != 0) { s[i-1] = u'-'; @@ -161,7 +161,7 @@ static QString int2string(int num, int base, int ndigits, bool *oflow) } } if (oflow) - *oflow = (int)s.length() > ndigits; + *oflow = (int)s.size() > ndigits; return s; } @@ -186,10 +186,10 @@ static QString double2string(double num, int base, int ndigits, bool *oflow) s[i] = u' '; s[i+1] = u'e'; } - } while (nd-- && (int)s.length() > ndigits); + } while (nd-- && (int)s.size() > ndigits); } if (oflow) - *oflow = (int)s.length() > ndigits; + *oflow = (int)s.size() > ndigits; return s; } @@ -679,7 +679,7 @@ void QLCDNumberPrivate::internalSetString(const QString& s) Q_Q(QLCDNumber); QString buffer(ndigits, QChar()); int i; - int len = s.length(); + int len = s.size(); QBitArray newPoints(ndigits); if (!smallPoint) { diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index b87d7e09cc..c38f3db7a1 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1611,7 +1611,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) if (d->control->composeMode()) { int preeditPos = d->control->cursor(); int posInPreedit = position - d->control->cursor(); - int preeditLength = d->control->preeditAreaText().length(); + int preeditLength = d->control->preeditAreaText().size(); bool positionOnPreedit = false; if (posInPreedit >= 0 && posInPreedit <= preeditLength) @@ -2123,13 +2123,13 @@ void QLineEdit::dropEvent(QDropEvent* e) if (e->source() == this) { if (e->dropAction() == Qt::MoveAction) { if (selStart > oldSelStart && selStart <= oldSelEnd) - setSelection(oldSelStart, str.length()); + setSelection(oldSelStart, str.size()); else if (selStart > oldSelEnd) - setSelection(selStart - str.length(), str.length()); + setSelection(selStart - str.size(), str.size()); else - setSelection(selStart, str.length()); + setSelection(selStart, str.size()); } else { - setSelection(selStart, str.length()); + setSelection(selStart, str.size()); } } } else { diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index cdfe6df7f6..e846600149 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -279,7 +279,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) if ( control->composeMode() ) { int tmp_cursor = xToPos(e->position().toPoint().x()); int mousePos = tmp_cursor - control->cursor(); - if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) + if ( mousePos < 0 || mousePos > control->preeditAreaText().size() ) mousePos = -1; if (mousePos >= 0) { diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 73ca584c7f..256e97396b 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1124,7 +1124,7 @@ QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) co QList<QDockWidget*> ret; const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); if (info && info->tabbed && info->tabBar) { - for(int i = 0; i < info->item_list.count(); ++i) { + for(int i = 0; i < info->item_list.size(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); if (item.widgetItem) { if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) { diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index dc90731c68..5ba065f084 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -106,7 +106,7 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QSt indent += " "_L1; - for (int i = 0; i < layout.item_list.count(); ++i) { + for (int i = 0; i < layout.item_list.size(); ++i) { qout << indent << "Item: " << i << '\n'; dumpLayout(qout, layout.item_list.at(i), indent + " "_L1); } @@ -366,7 +366,7 @@ QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const } } if (!dw) { - for (int i = 0; !dw && i < info->item_list.count(); ++i) { + for (int i = 0; !dw && i < info->item_list.size(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); if (item.skip()) continue; @@ -1470,7 +1470,7 @@ inline static Qt::DockWidgetArea toDockWidgetArea(int pos) #if QT_CONFIG(dockwidget) static bool isAreaAllowed(QWidget *widget, const QList<int> &path) { - Q_ASSERT_X((path.count() > 1), "isAreaAllowed", "invalid path size"); + Q_ASSERT_X((path.size() > 1), "isAreaAllowed", "invalid path size"); const Qt::DockWidgetArea area = toDockWidgetArea(path[1]); // Read permissions directly from a single dock widget @@ -1485,7 +1485,7 @@ static bool isAreaAllowed(QWidget *widget, const QList<int> &path) if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) { const QList<QDockWidget *> children = dwgw->findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly); - if (children.count() == 1) { + if (children.size() == 1) { // Group window has a single child => read its permissions const bool allowed = children.at(0)->isAreaAllowed(area); if (!allowed) @@ -1493,7 +1493,7 @@ static bool isAreaAllowed(QWidget *widget, const QList<int> &path) return allowed; } else { // Group window has more than one or no children => dock it anywhere - qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "has" << children.count() << "children:"; + qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "has" << children.size() << "children:"; qCDebug(lcQpaDockWidgets) << children; qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "can dock at" << area << "and anywhere else."; return true; diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index afa89b243b..b4d7785d94 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -750,7 +750,7 @@ void QMdiAreaPrivate::_q_currentTabChanged(int index) // If the previous active sub-window was hidden, disable the tab. if (indexToLastActiveTab >= 0 && indexToLastActiveTab < tabBar->count() - && indexToLastActiveTab < childWindows.count()) { + && indexToLastActiveTab < childWindows.size()) { QMdiSubWindow *lastActive = childWindows.at(indexToLastActiveTab); if (lastActive && lastActive->isHidden()) tabBar->setTabEnabled(indexToLastActiveTab, false); @@ -824,7 +824,7 @@ void QMdiAreaPrivate::appendChild(QMdiSubWindow *child) if (tabBar) { tabBar->addTab(child->windowIcon(), tabTextFor(child)); updateTabBarGeometry(); - if (childWindows.count() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation)) + if (childWindows.size() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation)) showActiveWindowMaximized = true; } #endif @@ -919,7 +919,7 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger) QRect domain = viewport->rect(); if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) - domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); + domain = resizeToMinimumTileSize(minSubWindowSize, widgets.size()); rearranger->rearrange(widgets, domain); @@ -1296,7 +1296,7 @@ bool QMdiAreaPrivate::scrollBarsEnabled() const */ bool QMdiAreaPrivate::lastWindowAboutToBeDestroyed() const { - if (childWindows.count() != 1) + if (childWindows.size() != 1) return false; QMdiSubWindow *last = childWindows.at(0); @@ -1372,7 +1372,7 @@ QMdiAreaPrivate::subWindowList(QMdiArea::WindowOrder order, bool reversed) const } } else { // ActivationHistoryOrder Q_ASSERT(indicesToActivatedChildren.size() == childWindows.size()); - for (int i = indicesToActivatedChildren.count() - 1; i >= 0; --i) { + for (int i = indicesToActivatedChildren.size() - 1; i >= 0; --i) { QMdiSubWindow *child = childWindows.at(indicesToActivatedChildren.at(i)); if (!child) continue; @@ -1761,7 +1761,7 @@ QMdiSubWindow *QMdiArea::currentSubWindow() const if (d->isActivated && !window()->isMinimized()) return nullptr; - Q_ASSERT(d->indicesToActivatedChildren.count() > 0); + Q_ASSERT(d->indicesToActivatedChildren.size() > 0); int index = d->indicesToActivatedChildren.at(0); Q_ASSERT(index >= 0 && index < d->childWindows.size()); QMdiSubWindow *current = d->childWindows.at(index); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index eaca88dfa7..d16a68b91b 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -110,7 +110,7 @@ public: //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*))); //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*))); QList<QAction*> items = p->actions(); - for(int i = 0; i < items.count(); i++) + for(int i = 0; i < items.size(); i++) addAction(items.at(i)); d->setMenuSize(sizeHint()); d->initialized = true; @@ -335,7 +335,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const q->ensurePolished(); //let's reinitialize the buffer - actionRects.resize(actions.count()); + actionRects.resize(actions.size()); actionRects.fill(QRect()); int lastVisibleAction = getLastVisibleAction(); @@ -360,7 +360,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const hasCheckableItems = false; ncols = 1; - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { QAction *action = actions.at(i); if (action->isSeparator() || !action->isVisible() || widgetItems.contains(action)) continue; @@ -454,7 +454,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const int x = hmargin + fw + leftmargin; y = base_y; - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QRect &rect = actionRects[i]; if (rect.isNull()) continue; @@ -479,7 +479,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const int QMenuPrivate::getLastVisibleAction() const { //let's try to get the last visible action - int lastVisibleAction = actions.count() - 1; + int lastVisibleAction = actions.size() - 1; for (;lastVisibleAction >= 0; --lastVisibleAction) { const QAction *action = actions.at(lastVisibleAction); if (action->isVisible()) { @@ -661,7 +661,7 @@ void QMenuPrivate::setFirstActionActive() { Q_Q(QMenu); updateActionRects(); - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { const QRect &rect = actionRects.at(i); if (rect.isNull()) continue; @@ -898,7 +898,7 @@ QAction *QMenuPrivate::actionAt(QPoint p) const if (!rect().contains(p)) //sanity check return nullptr; - for(int i = 0; i < actionRects.count(); i++) { + for(int i = 0; i < actionRects.size(); i++) { if (actionRects.at(i).contains(p)) return actions.at(i); } @@ -1109,7 +1109,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); if (location == QMenuScroller::ScrollTop) { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { if (actions.at(i) == action) { newOffset = topScroll - saccum; break; @@ -1117,7 +1117,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc saccum += actionRects.at(i).height(); } } else { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { saccum += actionRects.at(i).height(); if (actions.at(i) == action) { if (location == QMenuScroller::ScrollCenter) @@ -1136,7 +1136,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc if (newOffset < 0) //easy and cheap one newScrollFlags |= QMenuScroller::ScrollUp; int saccum = newOffset; - for(int i = 0; i < actionRects.count(); i++) { + for(int i = 0; i < actionRects.size(); i++) { saccum += actionRects.at(i).height(); if (saccum > q->height()) { newScrollFlags |= QMenuScroller::ScrollDown; @@ -1193,7 +1193,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc const int delta = qMin(0, newOffset) - scroll->scrollOffset; //make sure the new offset is always negative if (!itemsDirty && delta) { //we've scrolled so we need to update the action rects - for (int i = 0; i < actionRects.count(); ++i) { + for (int i = 0; i < actionRects.size(); ++i) { QRect ¤t = actionRects[i]; current.moveTop(current.top() + delta); @@ -1260,7 +1260,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); const int offset = topScroll ? topScroll-vmargin : 0; if (direction == QMenuScroller::ScrollUp) { - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { saccum -= actionRects.at(i).height(); if (saccum <= scroll->scrollOffset-offset) { scrollMenu(actions.at(i), page ? QMenuScroller::ScrollBottom : QMenuScroller::ScrollTop, active); @@ -1269,13 +1269,13 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag } } else if (direction == QMenuScroller::ScrollDown) { bool scrolled = false; - for(int i = 0, saccum = 0; i < actions.count(); i++) { + for(int i = 0, saccum = 0; i < actions.size(); i++) { const int iHeight = actionRects.at(i).height(); saccum -= iHeight; if (saccum <= scroll->scrollOffset-offset) { const int scrollerArea = q->height() - botScroll - fw*2; int visible = (scroll->scrollOffset-offset) - saccum; - for(i++ ; i < actions.count(); i++) { + for(i++ ; i < actions.size(); i++) { visible += actionRects.at(i).height(); if (visible > scrollerArea - topScroll) { scrolled = true; @@ -2173,7 +2173,7 @@ QAction *QMenu::activeAction() const bool QMenu::isEmpty() const { bool ret = true; - for(int i = 0; ret && i < actions().count(); ++i) { + for(int i = 0; ret && i < actions().size(); ++i) { const QAction *action = actions().at(i); if (!action->isSeparator() && action->isVisible()) { ret = false; @@ -2238,7 +2238,7 @@ QSize QMenu::sizeHint() const d->updateActionRects(); QSize s; - for (int i = 0; i < d->actionRects.count(); ++i) { + for (int i = 0; i < d->actionRects.size(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) continue; @@ -2395,7 +2395,7 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po if (ncols > 1) { pos.setY(screen.top() + desktopFrame); } else if (atAction) { - for (int i = 0, above_height = 0; i < actions.count(); i++) { + for (int i = 0, above_height = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (action == atAction) { int newY = pos.y() - above_height; @@ -2410,7 +2410,7 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po if (scroll && scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone && !q->style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, q)) { int below_height = above_height + scroll->scrollOffset; - for (int i2 = i; i2 < actionRects.count(); i2++) + for (int i2 = i; i2 < actionRects.size(); i2++) below_height += actionRects.at(i2).height(); size.setHeight(below_height); } @@ -2744,7 +2744,7 @@ void QMenu::paintEvent(QPaintEvent *e) //draw the items that need updating.. QRect scrollUpTearOffRect = scrollUpRect.united(tearOffRect); - for (int i = 0; i < d->actions.count(); ++i) { + for (int i = 0; i < d->actions.size(); ++i) { QAction *action = d->actions.at(i); QRect actionRect = d->actionRects.at(i); if (!e->rect().intersects(actionRect) @@ -3088,7 +3088,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay; if (!d->currentAction) { if (key == Qt::Key_Down) { - for(int i = 0; i < d->actions.count(); ++i) { + for(int i = 0; i < d->actions.size(); ++i) { QAction *act = d->actions.at(i); if (d->actionRects.at(i).isNull()) continue; @@ -3100,7 +3100,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } } else { - for(int i = d->actions.count()-1; i >= 0; --i) { + for(int i = d->actions.size()-1; i >= 0; --i) { QAction *act = d->actions.at(i); if (d->actionRects.at(i).isNull()) continue; @@ -3113,7 +3113,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } } else { - for(int i = 0, y = 0; !nextAction && i < d->actions.count(); i++) { + for(int i = 0, y = 0; !nextAction && i < d->actions.size(); i++) { QAction *act = d->actions.at(i); if (act == d->currentAction) { if (key == Qt::Key_Up) { @@ -3123,7 +3123,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) break; if (d->scroll) scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; - next_i = d->actionRects.count()-1; + next_i = d->actionRects.size()-1; } QAction *next = d->actions.at(next_i); if (next == d->currentAction) @@ -3149,7 +3149,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } else { y += d->actionRects.at(i).height(); for(int next_i = i+1; true; next_i++) { - if (next_i == d->actionRects.count()) { + if (next_i == d->actionRects.size()) { if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this)) break; if (d->scroll) @@ -3306,7 +3306,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (!key_consumed) { // send to menu bar if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) && - e->text().length()==1) { + e->text().size()==1) { bool activateAction = false; QAction *nextAction = nullptr; if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, nullptr, this) && !e->modifiers()) { diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 15c6f521b3..01ad37cab0 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -168,7 +168,7 @@ void QMenuBarPrivate::updateGeometries() for(int j = 0; j < shortcutIndexMap.size(); ++j) q->releaseShortcut(shortcutIndexMap.value(j)); shortcutIndexMap.clear(); - const int actionsCount = actions.count(); + const int actionsCount = actions.size(); shortcutIndexMap.reserve(actionsCount); for (int i = 0; i < actionsCount; i++) shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); @@ -182,7 +182,7 @@ void QMenuBarPrivate::updateGeometries() //we try to see if the actions will fit there bool hasHiddenActions = false; - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { const QRect &rect = actionRects.at(i); if (rect.isValid() && !menuRect.contains(rect)) { hasHiddenActions = true; @@ -193,7 +193,7 @@ void QMenuBarPrivate::updateGeometries() //...and if not, determine the ones that fit on the menu with the extension visible if (hasHiddenActions) { menuRect = this->menuRect(true); - for (int i = 0; i < actions.count(); ++i) { + for (int i = 0; i < actions.size(); ++i) { const QRect &rect = actionRects.at(i); if (rect.isValid() && !menuRect.contains(rect)) { hiddenActions.append(actions.at(i)); @@ -201,7 +201,7 @@ void QMenuBarPrivate::updateGeometries() } } - if (hiddenActions.count() > 0) { + if (hiddenActions.size() > 0) { QMenu *pop = extension->menu(); if (!pop) { pop = new QMenu(q); @@ -229,7 +229,7 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const //makes sure the geometries are up-to-date const_cast<QMenuBarPrivate*>(this)->updateGeometries(); - if (index < 0 || index >= actionRects.count()) + if (index < 0 || index >= actionRects.size()) return QRect(); // that can happen in case of native menubar return actionRects.at(index); @@ -240,8 +240,8 @@ void QMenuBarPrivate::focusFirstAction() if (!currentAction) { updateGeometries(); int index = 0; - while (index < actions.count() && actionRects.at(index).isNull()) ++index; - if (index < actions.count()) + while (index < actions.size() && actionRects.at(index).isNull()) ++index; + if (index < actions.size()) setCurrentAction(actions.at(index)); } } @@ -378,7 +378,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const return; //let's reinitialize the buffer - actionRects.resize(actions.count()); + actionRects.resize(actions.size()); actionRects.fill(QRect()); const QStyle *style = q->style(); @@ -391,7 +391,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q), vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q), icone = style->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q); - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (!action->isVisible()) continue; @@ -437,7 +437,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); int x = fw + ((start == -1) ? hmargin : start) + itemSpacing; int y = fw + vmargin; - for(int i = 0; i < actions.count(); i++) { + for(int i = 0; i < actions.size(); i++) { QRect &rect = actionRects[i]; if (rect.isNull()) continue; @@ -680,8 +680,8 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c Q_Q(const QMenuBar); const_cast<QMenuBarPrivate*>(this)->updateGeometries(); bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q); - const int start = (_start == -1 && increment == -1) ? actions.count() : _start; - const int end = increment == -1 ? 0 : actions.count() - 1; + const int start = (_start == -1 && increment == -1) ? actions.size() : _start; + const int end = increment == -1 ? 0 : actions.size() - 1; for (int i = start; i != end;) { i += increment; @@ -884,7 +884,7 @@ void QMenuBar::paintEvent(QPaintEvent *e) QRegion emptyArea(rect()); //draw the items - for (int i = 0; i < d->actions.count(); ++i) { + for (int i = 0; i < d->actions.size(); ++i) { QAction *action = d->actions.at(i); QRect adjustedActionRect = d->actionRect(action); if (adjustedActionRect.isEmpty() || !d->isVisible(action)) @@ -1060,7 +1060,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) if (!key_consumed && (!e->modifiers() || - (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) { + (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().size()==1 && !d->popupState) { int clashCount = 0; QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr; { @@ -1525,7 +1525,7 @@ QSize QMenuBar::minimumSizeHint() const if (as_gui_menubar) { int w = parentWidget() ? parentWidget()->width() : QGuiApplication::primaryScreen()->virtualGeometry().width(); d->calcActionRects(w - (2 * fw), 0); - for (int i = 0; ret.isNull() && i < d->actions.count(); ++i) + for (int i = 0; ret.isNull() && i < d->actions.size(); ++i) ret = d->actionRects.at(i).size(); if (!d->extension->isHidden()) ret += QSize(d->extension->sizeHint().width(), 0); @@ -1575,7 +1575,7 @@ QSize QMenuBar::sizeHint() const if (as_gui_menubar) { const int w = parentWidget() ? parentWidget()->width() : QGuiApplication::primaryScreen()->virtualGeometry().width(); d->calcActionRects(w - (2 * fw), 0); - for (int i = 0; i < d->actionRects.count(); ++i) { + for (int i = 0; i < d->actionRects.size(); ++i) { const QRect &actionRect = d->actionRects.at(i); ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height())); } @@ -1622,7 +1622,7 @@ int QMenuBar::heightForWidth(int) const int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this); int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this); if (as_gui_menubar) { - for (int i = 0; i < d->actionRects.count(); ++i) + for (int i = 0; i < d->actionRects.size(); ++i) height = qMax(height, d->actionRects.at(i).height()); if (height) //there is at least one non-null item height += spaceBelowMenuBar; diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index a954d6ce66..84c3799494 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -361,7 +361,7 @@ void QSplitterPrivate::init() void QSplitterPrivate::recalc(bool update) { Q_Q(QSplitter); - int n = list.count(); + int n = list.size(); /* Splitter handles before the first visible widget or right before a hidden widget must be hidden. @@ -451,7 +451,7 @@ void QSplitterPrivate::doResize() { Q_Q(QSplitter); QRect r = q->contentsRect(); - int n = list.count(); + int n = list.size(); QList<QLayoutStruct> a(n * 2); int i; @@ -565,7 +565,7 @@ int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int return index; } index += delta; - } while (index >= 0 && index < list.count()); + } while (index >= 0 && index < list.size()); return -1; } @@ -577,7 +577,7 @@ int QSplitterPrivate::findWidgetJustBeforeOrJustAfter(int index, int delta, int void QSplitterPrivate::getRange(int index, int *farMin, int *min, int *max, int *farMax) const { Q_Q(const QSplitter); - int n = list.count(); + int n = list.size(); if (index <= 0 || index >= n) return; @@ -757,7 +757,7 @@ void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool all void QSplitterPrivate::doMove(bool backwards, int hPos, int index, int delta, bool mayCollapse, int *positions, int *widths) { - if (index < 0 || index >= list.count()) + if (index < 0 || index >= list.size()) return; #ifdef QSPLITTER_DEBUG @@ -827,7 +827,7 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) Q_Q(QSplitter); QSplitterLayoutStruct *sls = nullptr; int i; - int last = list.count(); + int last = list.size(); for (i = 0; i < list.size(); ++i) { QSplitterLayoutStruct *s = list.at(i); if (s->widget == w) { @@ -1079,7 +1079,7 @@ void QSplitter::resizeEvent(QResizeEvent *) void QSplitter::addWidget(QWidget *widget) { Q_D(QSplitter); - insertWidget(d->list.count(), widget); + insertWidget(d->list.size(), widget); } /*! @@ -1129,7 +1129,7 @@ QWidget *QSplitter::replaceWidget(int index, QWidget *widget) return nullptr; } - if (index < 0 || index >= d->list.count()) { + if (index < 0 || index >= d->list.size()) { qWarning("QSplitter::replaceWidget: Index %d out of range", index); return nullptr; } @@ -1242,7 +1242,7 @@ QWidget *QSplitter::widget(int index) const int QSplitter::count() const { Q_D(const QSplitter); - return d->list.count(); + return d->list.size(); } /*! @@ -1271,7 +1271,7 @@ void QSplitter::childEvent(QChildEvent *c) } QWidget *w = static_cast<QWidget*>(c->child()); if (!d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) - d->insertWidget_helper(d->list.count(), w, false); + d->insertWidget_helper(d->list.size(), w, false); } else if (c->polished()) { if (!c->child()->isWidgetType()) return; @@ -1398,15 +1398,15 @@ void QSplitter::moveSplitter(int pos, int index) qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; #endif - QVarLengthArray<int, 32> poss(d->list.count()); - QVarLengthArray<int, 32> ws(d->list.count()); + QVarLengthArray<int, 32> poss(d->list.size()); + QVarLengthArray<int, 32> ws(d->list.size()); bool upLeft; d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data()); upLeft = (pos < oldP); - int wid, delta, count = d->list.count(); + int wid, delta, count = d->list.size(); if (upLeft) { wid = 0; delta = 1; @@ -1751,7 +1751,7 @@ bool QSplitter::restoreState(const QByteArray &state) void QSplitter::setStretchFactor(int index, int stretch) { Q_D(QSplitter); - if (index <= -1 || index >= d->list.count()) + if (index <= -1 || index >= d->list.size()) return; QWidget *widget = d->list.at(index)->widget; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 29b568f29d..ad6d28c523 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -404,7 +404,7 @@ int QTabBarPrivate::indexAtPos(const QPoint &p) const Q_Q(const QTabBar); if (q->tabRect(currentIndex).contains(p)) return currentIndex; - for (int i = 0; i < tabList.count(); ++i) + for (int i = 0; i < tabList.size(); ++i) if (tabList.at(i)->enabled && q->tabRect(i).contains(p)) return i; return -1; @@ -422,7 +422,7 @@ void QTabBarPrivate::layoutTabs() int hiddenTabs = 0; Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, nullptr, q)); - QList<QLayoutStruct> tabChain(tabList.count() + 2); + QList<QLayoutStruct> tabChain(tabList.size() + 2); // We put an empty item at the front and back and set its expansive attribute // depending on tabAlignment and expanding. @@ -445,7 +445,7 @@ void QTabBarPrivate::layoutTabs() int minx = 0; int x = 0; int maxHeight = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { const auto tab = tabList.at(i); if (!tab->visible) { ++hiddenTabs; @@ -476,7 +476,7 @@ void QTabBarPrivate::layoutTabs() int miny = 0; int y = 0; int maxWidth = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { auto tab = tabList.at(i); if (!tab->visible) { ++hiddenTabs; @@ -511,14 +511,14 @@ void QTabBarPrivate::layoutTabs() && (tabAlignment != Qt::AlignRight) && (tabAlignment != Qt::AlignJustify); tabChain[tabChainIndex].empty = true; - Q_ASSERT(tabChainIndex == tabChain.count() - 1 - hiddenTabs); // add an assert just to make sure. + Q_ASSERT(tabChainIndex == tabChain.size() - 1 - hiddenTabs); // add an assert just to make sure. // Do the calculation - qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0); + qGeomCalc(tabChain, 0, tabChain.size(), 0, qMax(available, last), 0); // Use the results hiddenTabs = 0; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { auto tab = tabList.at(i); if (!tab->visible) { tab->rect = QRect(); @@ -532,7 +532,7 @@ void QTabBarPrivate::layoutTabs() tab->rect.setRect(0, lstruct.pos, maxExtent, lstruct.size); } - if (useScrollButtons && tabList.count() && last > available) { + if (useScrollButtons && tabList.size() && last > available) { const QRect scrollRect = normalizedScrollRect(0); scrollOffset = -scrollRect.left(); @@ -768,7 +768,7 @@ void QTabBarPrivate::_q_closeTab() QObject *object = q->sender(); int tabToClose = -1; QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, q); - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { if (closeSide == QTabBar::LeftSide) { if (tabList.at(i)->leftWidget == object) { tabToClose = i; @@ -795,7 +795,7 @@ void QTabBarPrivate::_q_scrollTabs() int i = -1; if (sender == leftB) { - for (i = tabList.count() - 1; i >= 0; --i) { + for (i = tabList.size() - 1; i >= 0; --i) { int start = horizontal ? tabList.at(i)->rect.left() : tabList.at(i)->rect.top(); if (start < scrollRect.left()) { makeVisible(i); @@ -803,7 +803,7 @@ void QTabBarPrivate::_q_scrollTabs() } } } else if (sender == rightB) { - for (i = 0; i < tabList.count(); ++i) { + for (i = 0; i < tabList.size(); ++i) { const auto tabRect = tabList.at(i)->rect; int start = horizontal ? tabRect.left() : tabRect.top(); int end = horizontal ? tabRect.right() : tabRect.bottom(); @@ -950,7 +950,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) { Q_D(QTabBar); if (!d->validIndex(index)) { - index = d->tabList.count(); + index = d->tabList.size(); d->tabList.append(new QTabBarPrivate::Tab(icon, text)); } else { d->tabList.insert(index, new QTabBarPrivate::Tab(icon, text)); @@ -960,7 +960,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) #endif d->firstVisible = qMax(qMin(index, d->firstVisible), 0); d->refresh(); - if (d->tabList.count() == 1) + if (d->tabList.size() == 1) setCurrentIndex(index); else if (index <= d->currentIndex) ++d->currentIndex; @@ -1469,7 +1469,7 @@ void QTabBar::setIconSize(const QSize &size) int QTabBar::count() const { Q_D(const QTabBar); - return d->tabList.count(); + return d->tabList.size(); } @@ -1512,7 +1512,7 @@ QSize QTabBar::minimumSizeHint() const // Compute the most-elided possible text, for minimumSizeHint static QString computeElidedText(Qt::TextElideMode mode, const QString &text) { - if (text.length() <= 3) + if (text.size() <= 3) return text; static const auto Ellipses = "..."_L1; @@ -1721,7 +1721,7 @@ bool QTabBar::event(QEvent *event) case QEvent::Shortcut: { QShortcutEvent *se = static_cast<QShortcutEvent *>(event); - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { const QTabBarPrivate::Tab *tab = d->tabList.at(i); if (tab->shortcutId == se->shortcutId()) { setCurrentIndex(i); @@ -1804,7 +1804,7 @@ void QTabBar::paintEvent(QPaintEvent *) selected = d->pressedIndex; const QRect scrollRect = d->normalizedScrollRect(); - for (int i = 0; i < d->tabList.count(); ++i) + for (int i = 0; i < d->tabList.size(); ++i) optTabBase.tabBarRect |= tabRect(i); optTabBase.selectedTabRect = tabRect(selected); @@ -1826,7 +1826,7 @@ void QTabBar::paintEvent(QPaintEvent *) p.setClipRegion(QRegion(rect()) - buttonRegion); } - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { const auto tab = d->tabList.at(i); if (!tab->visible) continue; @@ -1916,7 +1916,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem } else { if (remove || (index == firstVisible)) { firstVisible = -1; - for (int i = 0; i < tabList.count(); ++i) { + for (int i = 0; i < tabList.size(); ++i) { if (tabList.at(i)->visible) { firstVisible = i; break; @@ -1925,7 +1925,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem } if (remove || (index == lastVisible)) { lastVisible = -1; - for (int i = tabList.count() - 1; i >= 0; --i) { + for (int i = tabList.size() - 1; i >= 0; --i) { if (tabList.at(i)->visible) { lastVisible = i; break; @@ -1943,7 +1943,7 @@ void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool rem int QTabBarPrivate::selectNewCurrentIndexFrom(int fromIndex) { int newindex = -1; - for (int i = fromIndex; i < tabList.count(); ++i) { + for (int i = fromIndex; i < tabList.size(); ++i) { if (at(i)->visible && at(i)->enabled) { newindex = i; break; @@ -2557,7 +2557,7 @@ void QTabBar::setTabsClosable(bool closable) } } else { bool newButtons = false; - for (int i = 0; i < d->tabList.count(); ++i) { + for (int i = 0; i < d->tabList.size(); ++i) { if (tabButton(i, closeSide)) continue; newButtons = true; @@ -2766,7 +2766,7 @@ void QTabBar::setChangeCurrentOnDrag(bool change) void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget) { Q_D(QTabBar); - if (index < 0 || index >= d->tabList.count()) + if (index < 0 || index >= d->tabList.size()) return; if (widget) { widget->setParent(this); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index e38b1ef6f9..a421836b93 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -184,7 +184,7 @@ public: int indexAtPos(const QPoint &p) const; inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0; } - inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } + inline bool validIndex(int index) const { return index >= 0 && index < tabList.size(); } void setCurrentNextEnabledIndex(int offset); void _q_scrollTabs(); diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 2bab2efc61..63edfc5328 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -64,13 +64,13 @@ public: HistoryEntry history(int i) const { if (i <= 0) - if (-i < stack.count()) - return stack[stack.count()+i-1]; + if (-i < stack.size()) + return stack[stack.size()+i-1]; else return HistoryEntry(); else - if (i <= forwardStack.count()) - return forwardStack[forwardStack.count()-i]; + if (i <= forwardStack.size()) + return forwardStack[forwardStack.size()-i]; else return HistoryEntry(); } @@ -828,11 +828,11 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type entry.vpos = 0; d->stack.push(entry); - emit backwardAvailable(d->stack.count() > 1); + emit backwardAvailable(d->stack.size() > 1); if (!d->forwardStack.isEmpty() && d->forwardStack.top().url == url) { d->forwardStack.pop(); - emit forwardAvailable(d->forwardStack.count() > 0); + emit forwardAvailable(d->forwardStack.size() > 0); } else { d->forwardStack.clear(); emit forwardAvailable(false); @@ -906,14 +906,14 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type void QTextBrowser::backward() { Q_D(QTextBrowser); - if (d->stack.count() <= 1) + if (d->stack.size() <= 1) return; // Update the history entry d->forwardStack.push(d->createHistoryEntry()); d->stack.pop(); // throw away the old version of the current entry d->restoreHistoryEntry(d->stack.top()); // previous entry - emit backwardAvailable(d->stack.count() > 1); + emit backwardAvailable(d->stack.size() > 1); emit forwardAvailable(true); emit historyChanged(); } @@ -1156,7 +1156,7 @@ QVariant QTextBrowser::loadResource(int /*type*/, const QUrl &name) bool QTextBrowser::isBackwardAvailable() const { Q_D(const QTextBrowser); - return d->stack.count() > 1; + return d->stack.size() > 1; } /*! @@ -1243,7 +1243,7 @@ QString QTextBrowser::historyTitle(int i) const int QTextBrowser::forwardHistoryCount() const { Q_D(const QTextBrowser); - return d->forwardStack.count(); + return d->forwardStack.size(); } /*! @@ -1254,7 +1254,7 @@ int QTextBrowser::forwardHistoryCount() const int QTextBrowser::backwardHistoryCount() const { Q_D(const QTextBrowser); - return d->stack.count()-1; + return d->stack.size()-1; } /*! diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index b3a8963431..f3d1d3e511 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1371,7 +1371,7 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) const QString text = e->text(); if (cursor.atBlockStart() && (d->autoFormatting & AutoBulletList) - && (text.length() == 1) + && (text.size() == 1) && (text.at(0) == u'-' || text.at(0) == u'*') && (!cursor.currentList())) { diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 6334874a4c..54c21b6038 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -70,7 +70,7 @@ QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation) QSize QToolBarAreaLayoutLine::sizeHint() const { int a = 0, b = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { const QToolBarAreaLayoutItem &item = toolBarItems.at(i); if (item.skip()) continue; @@ -90,7 +90,7 @@ QSize QToolBarAreaLayoutLine::sizeHint() const QSize QToolBarAreaLayoutLine::minimumSize() const { int a = 0, b = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { const QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -114,7 +114,7 @@ void QToolBarAreaLayoutLine::fitLayout() int space = pick(o, rect.size()); int extra = qMax(0, space - min); - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -137,7 +137,7 @@ void QToolBarAreaLayoutLine::fitLayout() // calculate the positions from the sizes int pos = 0; - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { QToolBarAreaLayoutItem &item = toolBarItems[i]; if (item.skip()) continue; @@ -151,7 +151,7 @@ void QToolBarAreaLayoutLine::fitLayout() bool QToolBarAreaLayoutLine::skip() const { - for (int i = 0; i < toolBarItems.count(); ++i) { + for (int i = 0; i < toolBarItems.size(); ++i) { if (!toolBarItems.at(i).skip()) return false; } @@ -183,7 +183,7 @@ QToolBarAreaLayoutInfo::QToolBarAreaLayoutInfo(QInternal::DockPosition pos) QSize QToolBarAreaLayoutInfo::sizeHint() const { int a = 0, b = 0; - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { const QToolBarAreaLayoutLine &l = lines.at(i); if (l.skip()) continue; @@ -203,7 +203,7 @@ QSize QToolBarAreaLayoutInfo::sizeHint() const QSize QToolBarAreaLayoutInfo::minimumSize() const { int a = 0, b = 0; - for (int i = 0; i < lines.count(); ++i) { + for (int i = 0; i < lines.size(); ++i) { const QToolBarAreaLayoutLine &l = lines.at(i); if (l.skip()) continue; @@ -228,9 +228,9 @@ void QToolBarAreaLayoutInfo::fitLayout() bool reverse = dockPos == QInternal::RightDock || dockPos == QInternal::BottomDock; - int i = reverse ? lines.count() - 1 : 0; + int i = reverse ? lines.size() - 1 : 0; for (;;) { - if ((reverse && i < 0) || (!reverse && i == lines.count())) + if ((reverse && i < 0) || (!reverse && i == lines.size())) break; QToolBarAreaLayoutLine &l = lines[i]; @@ -273,10 +273,10 @@ void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) return; } - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { line.toolBarItems.insert(k, item); return; @@ -287,17 +287,17 @@ void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar) { - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (item.widgetItem->widget() == toolBar) { delete item.widgetItem; item.widgetItem = nullptr; line.toolBarItems.removeAt(k); - if (line.toolBarItems.isEmpty() && j < lines.count() - 1) + if (line.toolBarItems.isEmpty() && j < lines.size() - 1) lines.removeAt(j); return; @@ -315,10 +315,10 @@ void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) return; } - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { if (k == 0) return; @@ -336,10 +336,10 @@ void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) void QToolBarAreaLayoutInfo::removeToolBarBreak(QToolBar *before) { - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { const QToolBarAreaLayoutLine &line = lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { if (k != 0) return; @@ -366,12 +366,12 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) pos -= rect.top(); //here we actually update the preferredSize for the line containing the toolbar so that we move it - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; int previousIndex = -1; int minPos = 0; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem ¤t = line.toolBarItems[k]; if (current.widgetItem->widget() == toolbar) { int newPos = current.pos; @@ -383,7 +383,7 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) } else { //we check the max value for the position (until everything at the right is "compressed") int maxPos = pick(o, rect.size()); - for(int l = k; l < line.toolBarItems.count(); ++l) { + for(int l = k; l < line.toolBarItems.size(); ++l) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(l); if (!item.skip()) { maxPos -= pick(o, item.minimumSize()); @@ -451,7 +451,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) // Since we're comparing p with item.pos, we put them in the same coordinate system. const int p = pick(o, pos - rect.topLeft()); - for (int j = 0; j < lines.count(); ++j) { + for (int j = 0; j < lines.size(); ++j) { const QToolBarAreaLayoutLine &line = lines.at(j); if (line.skip()) continue; @@ -459,7 +459,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) continue; int k = 0; - for (; k < line.toolBarItems.count(); ++k) { + for (; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (item.skip()) continue; @@ -485,7 +485,7 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) *minDistance = dist; QList<int> result; - result << lines.count() << 0; + result << lines.size() << 0; return result; } } @@ -495,9 +495,9 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(path.count() == 2); + Q_ASSERT(path.size() == 2); int j = path.first(); - if (j == lines.count()) + if (j == lines.size()) lines.append(QToolBarAreaLayoutLine(o)); QToolBarAreaLayoutLine &line = lines[j]; @@ -540,7 +540,7 @@ void QToolBarAreaLayoutInfo::clear() QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const { - Q_ASSERT(path.count() == 2); + Q_ASSERT(path.size() == 2); int j = path.at(0); int k = path.at(1); @@ -698,10 +698,10 @@ QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if ((*x)++ == index) return line.toolBarItems.at(k).widgetItem; } @@ -718,10 +718,10 @@ QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index) for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if ((*x)++ == index) { QLayoutItem *result = line.toolBarItems.takeAt(k).widgetItem; if (line.toolBarItems.isEmpty()) @@ -740,10 +740,10 @@ void QToolBarAreaLayout::deleteAllLayoutItems() for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (!item.gap) delete item.widgetItem; @@ -758,10 +758,10 @@ QInternal::DockPosition QToolBarAreaLayout::findToolBar(const QToolBar *toolBar) for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) return static_cast<QInternal::DockPosition>(i); } @@ -849,12 +849,12 @@ void QToolBarAreaLayout::apply(bool animate) for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); if (line.skip()) continue; - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (item.skip() || item.gap) continue; @@ -907,10 +907,10 @@ bool QToolBarAreaLayout::toolBarBreak(QToolBar *toolBar) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) return j > 0 && k == 0; } @@ -925,25 +925,25 @@ void QToolBarAreaLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBa for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == toolBar) { - if (line.toolBarItems.count() == 1) + if (line.toolBarItems.size() == 1) option->positionWithinLine = QStyleOptionToolBar::OnlyOne; else if (k == 0) option->positionWithinLine = QStyleOptionToolBar::Beginning; - else if (k == line.toolBarItems.count() - 1) + else if (k == line.toolBarItems.size() - 1) option->positionWithinLine = QStyleOptionToolBar::End; else option->positionWithinLine = QStyleOptionToolBar::Middle; - if (dock.lines.count() == 1) + if (dock.lines.size() == 1) option->positionOfLine = QStyleOptionToolBar::OnlyOne; else if (j == 0) option->positionOfLine = QStyleOptionToolBar::Beginning; - else if (j == dock.lines.count() - 1) + else if (j == dock.lines.size() - 1) option->positionOfLine = QStyleOptionToolBar::End; else option->positionOfLine = QStyleOptionToolBar::Middle; @@ -964,10 +964,10 @@ QList<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); if (!item.gap && item.widgetItem->widget() == toolBar) { found = true; @@ -1016,10 +1016,10 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); k++) { + for (int k = 0; k < line.toolBarItems.size(); k++) { if (line.toolBarItems[k].gap) { QList<int> result; result << i << j << k; @@ -1033,7 +1033,7 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); const int i = path.first(); Q_ASSERT(i >= 0 && i < QInternal::DockCount); return docks[i].insertGap(path.mid(1), item); @@ -1041,7 +1041,7 @@ bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) void QToolBarAreaLayout::remove(const QList<int> &path) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); QToolBarAreaLayoutInfo &dock = docks[path.at(0)]; QToolBarAreaLayoutLine &line = dock.lines[path.at(1)]; line.toolBarItems.removeAt(path.at(2)); @@ -1054,10 +1054,10 @@ void QToolBarAreaLayout::remove(QLayoutItem *item) for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { QToolBarAreaLayoutLine &line = dock.lines[j]; - for (int k = 0; k < line.toolBarItems.count(); k++) { + for (int k = 0; k < line.toolBarItems.size(); k++) { if (line.toolBarItems[k].widgetItem == item) { line.toolBarItems.removeAt(k); if (line.toolBarItems.isEmpty()) @@ -1078,15 +1078,15 @@ void QToolBarAreaLayout::clear() QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path) { - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount) return nullptr; QToolBarAreaLayoutInfo &info = docks[path.at(0)]; - if (path.at(1) < 0 || path.at(1) >= info.lines.count()) + if (path.at(1) < 0 || path.at(1) >= info.lines.size()) return nullptr; QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; - if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count()) + if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.size()) return nullptr; return &(line.toolBarItems[path.at(2)]); } @@ -1118,7 +1118,7 @@ QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other) { //other needs to be update as well - Q_ASSERT(path.count() == 3); + Q_ASSERT(path.size() == 3); QToolBarAreaLayoutItem *item = this->item(path); Q_ASSERT(item); @@ -1136,7 +1136,7 @@ QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayo if (!previous.skip()) { //we need to check if it has a previous element and a next one //the previous will get its size changed - for (int j = path.at(2) + 1; j < line.toolBarItems.count(); ++j) { + for (int j = path.at(2) + 1; j < line.toolBarItems.size(); ++j) { const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j); if (!next.skip()) { newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint()); @@ -1221,19 +1221,19 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const int lineCount = 0; for (int i = 0; i < QInternal::DockCount; ++i) - lineCount += docks[i].lines.count(); + lineCount += docks[i].lines.size(); stream << lineCount; for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; - for (int j = 0; j < dock.lines.count(); ++j) { + for (int j = 0; j < dock.lines.size(); ++j) { const QToolBarAreaLayoutLine &line = dock.lines.at(j); - stream << i << int(line.toolBarItems.count()); + stream << i << int(line.toolBarItems.size()); - for (int k = 0; k < line.toolBarItems.count(); ++k) { + for (int k = 0; k < line.toolBarItems.size(); ++k) { const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); QWidget *widget = const_cast<QLayoutItem*>(item.widgetItem)->widget(); QString objectName = widget->objectName(); @@ -1317,7 +1317,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar* } QToolBar *toolBar = nullptr; - for (int x = 0; x < toolBars.count(); ++x) { + for (int x = 0; x < toolBars.size(); ++x) { if (toolBars.at(x)->objectName() == objectName) { toolBar = toolBars.takeAt(x); break; diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index ebfece96d0..cc842e2657 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -132,14 +132,14 @@ void QToolBarLayout::addItem(QLayoutItem*) QLayoutItem *QToolBarLayout::itemAt(int index) const { - if (index < 0 || index >= items.count()) + if (index < 0 || index >= items.size()) return nullptr; return items.at(index); } QLayoutItem *QToolBarLayout::takeAt(int index) { - if (index < 0 || index >= items.count()) + if (index < 0 || index >= items.size()) return nullptr; QToolBarItem *item = items.takeAt(index); @@ -162,7 +162,7 @@ QLayoutItem *QToolBarLayout::takeAt(int index) void QToolBarLayout::insertAction(int index, QAction *action) { index = qMax(0, index); - index = qMin(items.count(), index); + index = qMin(items.size(), index); QToolBarItem *item = createItem(action); if (item) { @@ -173,7 +173,7 @@ void QToolBarLayout::insertAction(int index, QAction *action) int QToolBarLayout::indexOf(const QAction *action) const { - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { if (items.at(i)->action == action) return i; } @@ -182,7 +182,7 @@ int QToolBarLayout::indexOf(const QAction *action) const int QToolBarLayout::count() const { - return items.count(); + return items.size(); } bool QToolBarLayout::isEmpty() const @@ -246,10 +246,10 @@ void QToolBarLayout::updateGeomArray() const that->expanding = false; that->empty = false; - QList<QLayoutStruct> a(items.count() + 1); // + 1 for the stretch + QList<QLayoutStruct> a(items.size() + 1); // + 1 for the stretch int count = 0; - for (int i = 0; i < items.count(); ++i) { + for (int i = 0; i < items.size(); ++i) { QToolBarItem *item = items.at(i); QSize max = item->maximumSize(); @@ -296,7 +296,7 @@ void QToolBarLayout::updateGeomArray() const rpick(o, that->minSize) += handleExtent; that->minSize += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins)); - if (items.count() > 1) + if (items.size() > 1) rpick(o, that->minSize) += spacing + extensionExtent; rpick(o, that->hint) += handleExtent; @@ -431,7 +431,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) int rows = 0; int rowPos = perp(o, rect.topLeft()) + perp(o, QSize(margins.top(), margins.left())); int i = 0; - while (i < items.count()) { + while (i < items.size()) { QList<QLayoutStruct> a = geomArray; int start = i; @@ -441,7 +441,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) int count = 0; int maximumSize = 0; bool expansiveRow = false; - for (; i < items.count(); ++i) { + for (; i < items.size(); ++i) { if (a[i].empty) continue; @@ -512,7 +512,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) } if (!expanded) { - for (int j = i; j < items.count(); ++j) { + for (int j = i; j < items.size(); ++j) { QToolBarItem *item = items.at(j); if (!item->widget()->isHidden()) hideWidgets << item->widget(); @@ -537,9 +537,9 @@ bool QToolBarLayout::layoutActions(const QSize &size) extension->setEnabled(popupMenu == nullptr || !extensionMenuContainsOnlyWidgetActions); // we have to do the show/hide here, because it triggers more calls to setGeometry :( - for (int i = 0; i < showWidgets.count(); ++i) + for (int i = 0; i < showWidgets.size(); ++i) showWidgets.at(i)->show(); - for (int i = 0; i < hideWidgets.count(); ++i) + for (int i = 0; i < hideWidgets.size(); ++i) hideWidgets.at(i)->hide(); return ranOutOfSpace; @@ -566,7 +566,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const int total_w = 0; int count = 0; - for (int x = 0; x < items.count(); ++x) { + for (int x = 0; x < items.size(); ++x) { if (!geomArray[x].empty) { total_w += (count == 0 ? 0 : spacing) + geomArray[x].minimumSize; ++count; @@ -587,12 +587,12 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const int w = 0; int h = 0; int i = 0; - while (i < items.count()) { + while (i < items.size()) { int count = 0; int size = 0; int prev = -1; int rowHeight = 0; - for (; i < items.count(); ++i) { + for (; i < items.size(); ++i) { if (geomArray[i].empty) continue; diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index e95509ae89..30465b95fa 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -62,7 +62,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) if (m_echoMode == QLineEdit::Password) { str.fill(m_passwordCharacter); - if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { + if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.size()) { int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); str[cursor] = uc; @@ -82,7 +82,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) // drawing boxes when using fonts that don't have glyphs for such // characters) QChar* uc = str.data(); - for (int i = 0; i < (int)str.length(); ++i) { + for (int i = 0; i < (int)str.size(); ++i) { if ((uc[i].unicode() < 0x20 && uc[i].unicode() != 0x09) || uc[i] == QChar::LineSeparator || uc[i] == QChar::ParagraphSeparator @@ -242,7 +242,7 @@ void QWidgetLineControl::clear() { int priorState = m_undoState; m_selstart = 0; - m_selend = m_text.length(); + m_selend = m_text.size(); removeSelectedText(); separate(); finishChange(priorState, /*update*/false, /*edited*/false); @@ -286,7 +286,7 @@ void QWidgetLineControl::setSelection(int start, int length) if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) return; m_selstart = start; - m_selend = qMin(start + length, (int)m_text.length()); + m_selend = qMin(start + length, (int)m_text.size()); m_cursor = m_selend; } else if (length < 0){ if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) @@ -329,7 +329,7 @@ void QWidgetLineControl::init(const QString &txt) m_textLayout.setCacheEnabled(true); m_text = txt; updateDisplayText(); - m_cursor = m_text.length(); + m_cursor = m_text.size(); if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); m_passwordMaskDelay = theme->themeHint(QPlatformTheme::PasswordMaskDelay).toInt(); @@ -491,14 +491,14 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing()) { updatePasswordEchoEditing(true); m_selstart = 0; - m_selend = m_text.length(); + m_selend = m_text.size(); } removeSelectedText(); } int c = m_cursor; // cursor position after insertion of commit string if (event->replacementStart() <= 0) - c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); + c += event->commitString().size() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); if (m_cursor < 0) @@ -514,15 +514,15 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) internalInsert(event->commitString()); cursorPositionChanged = true; } else { - m_cursor = qBound(0, c, m_text.length()); + m_cursor = qBound(0, c, m_text.size()); } for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); if (a.type == QInputMethodEvent::Selection) { - m_cursor = qBound(0, a.start + a.length, m_text.length()); + m_cursor = qBound(0, a.start + a.length, m_text.size()); if (a.length) { - m_selstart = qMax(0, qMin(a.start, m_text.length())); + m_selstart = qMax(0, qMin(a.start, m_text.size())); m_selend = m_cursor; if (m_selend < m_selstart) { qSwap(m_selstart, m_selend); @@ -554,7 +554,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) } #endif //QT_NO_IM const int oldPreeditCursor = m_preeditCursor; - m_preeditCursor = event->preeditString().length(); + m_preeditCursor = event->preeditString().size(); m_hideCursor = false; QList<QTextLayout::FormatRange> formats; formats.reserve(event->attributes().size()); @@ -695,7 +695,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e } #endif if (validateFromState >= 0 && wasValidInput && !m_validInput) { - if (m_transactions.count()) + if (m_transactions.size()) return false; internalUndo(validateFromState); m_history.erase(m_history.begin() + m_undoState, m_history.end()); @@ -737,7 +737,7 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite QString oldText = m_text; if (m_maskData) { m_text = maskString(0, txt, true); - m_text += clearString(m_text.length(), m_maxLength - m_text.length()); + m_text += clearString(m_text.size(), m_maxLength - m_text.size()); if (edited && oldText == m_text) emit inputRejected(); } else { @@ -745,7 +745,7 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite } m_history.clear(); m_modifiedState = m_undoState = 0; - m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; + m_cursor = (pos < 0 || pos > m_text.size()) ? m_text.size() : pos; m_textDirty = (oldText != m_text); const bool changed = finishChange(-1, true, edited); @@ -823,12 +823,12 @@ void QWidgetLineControl::internalInsert(const QString &s) QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, ms); QAccessible::updateAccessibility(&insertEvent); #endif - for (int i = 0; i < (int) ms.length(); ++i) { + for (int i = 0; i < (int) ms.size(); ++i) { addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); } - m_text.replace(m_cursor, ms.length(), ms); - m_cursor += ms.length(); + m_text.replace(m_cursor, ms.size(), ms); + m_cursor += ms.size(); m_cursor = nextMaskBlank(m_cursor); m_textDirty = true; #if QT_CONFIG(accessibility) @@ -836,18 +836,18 @@ void QWidgetLineControl::internalInsert(const QString &s) QAccessible::updateAccessibility(&event); #endif } else { - int remaining = m_maxLength - m_text.length(); + int remaining = m_maxLength - m_text.size(); if (remaining != 0) { #if QT_CONFIG(accessibility) QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, s); QAccessible::updateAccessibility(&insertEvent); #endif m_text.insert(m_cursor, s.left(remaining)); - for (int i = 0; i < (int) s.left(remaining).length(); ++i) + for (int i = 0; i < (int) s.left(remaining).size(); ++i) addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); m_textDirty = true; } - if (s.length() > remaining) + if (s.size() > remaining) emit inputRejected(); } } @@ -865,7 +865,7 @@ void QWidgetLineControl::internalInsert(const QString &s) */ void QWidgetLineControl::internalDelete(bool wasBackspace) { - if (m_cursor < (int) m_text.length()) { + if (m_cursor < (int) m_text.size()) { cancelPasswordEchoTimer(); if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, u'\0', m_selstart, m_selend)); @@ -896,7 +896,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace) */ void QWidgetLineControl::removeSelectedText() { - if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { + if (m_selstart < m_selend && m_selend <= (int) m_text.size()) { cancelPasswordEchoTimer(); separate(); int i ; @@ -953,13 +953,13 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) m_inputMask = maskFields; } else { m_inputMask = maskFields.left(delimiter); - m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : u' '; + m_blank = (delimiter + 1 < maskFields.size()) ? maskFields[delimiter + 1] : u' '; } // calculate m_maxLength / m_maskData length m_maxLength = 0; bool escaped = false; - for (int i=0; i<m_inputMask.length(); i++) { + for (int i=0; i<m_inputMask.size(); i++) { const auto c = m_inputMask.at(i); if (escaped) { ++m_maxLength; @@ -983,7 +983,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) bool s; bool escape = false; int index = 0; - for (int i = 0; i < m_inputMask.length(); i++) { + for (int i = 0; i < m_inputMask.size(); i++) { const auto c = m_inputMask.at(i); if (escape) { s = true; @@ -1132,7 +1132,7 @@ bool QWidgetLineControl::hasAcceptableInput(const QString &str) const if (!m_maskData) return true; - if (str.length() != m_maxLength) + if (str.size() != m_maxLength) return false; for (int i=0; i < m_maxLength; ++i) { @@ -1167,7 +1167,7 @@ QString QWidgetLineControl::maskString(int pos, const QString &str, bool clear) QString s = QString::fromLatin1(""); int i = pos; while (i < m_maxLength) { - if (strIndex < str.length()) { + if (strIndex < str.size()) { if (m_maskData[i].separator) { s += m_maskData[i].maskChar; if (str[strIndex] == m_maskData[i].maskChar) @@ -1190,7 +1190,7 @@ QString QWidgetLineControl::maskString(int pos, const QString &str, bool clear) // search for separator first int n = findInMask(i, true, true, str[strIndex]); if (n != -1) { - if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) { + if (str.size() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) { s += QStringView{fill}.mid(i, n - i + 1); i = n + 1; // update i to find + 1 } @@ -1258,7 +1258,7 @@ QString QWidgetLineControl::stripString(const QString &str) const return str; QString s; - int end = qMin(m_maxLength, (int)str.length()); + int end = qMin(m_maxLength, (int)str.size()); for (int i = 0; i < end; ++i) if (m_maskData[i].separator) s += m_maskData[i].maskChar; @@ -1445,7 +1445,7 @@ void QWidgetLineControl::complete(int key) return; int n = 0; if (key == Qt::Key_Up || key == Qt::Key_Down) { - if (textAfterSelection().length()) + if (textAfterSelection().size()) return; QString prefix = hasSelectedText() ? textBeforeSelection() : text; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index eabe1d31c4..838a46fff6 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -115,7 +115,7 @@ public: bool isModified() const { return m_modifiedState != m_undoState; } void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; } - bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); } + bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.size(); } bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; } int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; } @@ -150,7 +150,7 @@ public: } int start() const { return 0; } - int end() const { return m_text.length(); } + int end() const { return m_text.size(); } #ifndef QT_NO_CLIPBOARD void copy(QClipboard::Mode mode = QClipboard::Clipboard) const; @@ -186,7 +186,7 @@ public: void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } void home(bool mark) { moveCursor(0, mark); } - void end(bool mark) { moveCursor(m_text.length(), mark); } + void end(bool mark) { moveCursor(m_text.size(), mark); } int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; QRect rectForPos(int pos) const; @@ -231,7 +231,7 @@ public: void backspace(); void del(); void deselect() { internalDeselect(); finishChange(); } - void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); } + void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.size(), true); } void insert(const QString &); void clear(); @@ -277,7 +277,7 @@ public: #endif int cursorPosition() const { return m_cursor; } - void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); } + void setCursorPosition(int pos) { if (pos <= m_text.size()) moveCursor(qMax(0, pos)); } bool hasAcceptableInput() const { return hasAcceptableInput(m_text); } bool fixup(); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index e9702e8977..1b78442ed1 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1403,7 +1403,7 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const if (relativePos == preeditPos) relativePos += preeditCursor; else if (relativePos > preeditPos) - relativePos += layout->preeditAreaText().length(); + relativePos += layout->preeditAreaText().size(); } QTextLine line = layout->lineForTextPosition(relativePos); @@ -1900,7 +1900,7 @@ bool QWidgetTextControlPrivate::sendMouseEventToInputContext( QTextLayout *layout = cursor.block().layout(); int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); - if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) + if (cursorPos < 0 || cursorPos > layout->preeditAreaText().size()) cursorPos = -1; if (cursorPos >= 0) { @@ -2060,7 +2060,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) QList<QTextLayout::FormatRange> overrides; overrides.reserve(e->attributes().size()); const int oldPreeditCursor = preeditCursor; - preeditCursor = e->preeditString().length(); + preeditCursor = e->preeditString().size(); hideCursor = false; for (int i = 0; i < e->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = e->attributes().at(i); @@ -2095,7 +2095,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) if (cursor.charFormat().isValid()) { int start = cursor.position() - block.position(); - int end = start + e->preeditString().length(); + int end = start + e->preeditString().size(); QList<QTextLayout::FormatRange>::iterator it = overrides.begin(); while (it != overrides.end()) { @@ -2168,7 +2168,7 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa QTextCursor tmpCursor = d->cursor; int localPos = d->cursor.position() - block.position(); QString result = block.text().mid(localPos); - while (result.length() < maxLength) { + while (result.size() < maxLength) { int currentBlock = tmpCursor.blockNumber(); tmpCursor.movePosition(QTextCursor::NextBlock); if (tmpCursor.blockNumber() == currentBlock) @@ -2475,12 +2475,12 @@ void QWidgetTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelectio Q_D(QWidgetTextControl); QMultiHash<int, int> hash; - for (int i = 0; i < d->extraSelections.count(); ++i) { + for (int i = 0; i < d->extraSelections.size(); ++i) { const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i); hash.insert(esel.cursor.anchor(), i); } - for (int i = 0; i < selections.count(); ++i) { + for (int i = 0; i < selections.size(); ++i) { const QTextEdit::ExtraSelection &sel = selections.at(i); const auto it = hash.constFind(sel.cursor.anchor()); if (it != hash.cend()) { @@ -2509,8 +2509,8 @@ void QWidgetTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelectio emit updateRequest(r); } - d->extraSelections.resize(selections.count()); - for (int i = 0; i < selections.count(); ++i) { + d->extraSelections.resize(selections.size()); + for (int i = 0; i < selections.size(); ++i) { d->extraSelections[i].cursor = selections.at(i).cursor; d->extraSelections[i].format = selections.at(i).format; } @@ -2520,7 +2520,7 @@ QList<QTextEdit::ExtraSelection> QWidgetTextControl::extraSelections() const { Q_D(const QWidgetTextControl); QList<QTextEdit::ExtraSelection> selections; - const int numExtraSelections = d->extraSelections.count(); + const int numExtraSelections = d->extraSelections.size(); selections.reserve(numExtraSelections); for (int i = 0; i < numExtraSelections; ++i) { QTextEdit::ExtraSelection sel; |