summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-30 14:09:04 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-04 07:40:08 +0200
commitdf9d882d41b741fef7c5beeddb0abe9d904443d8 (patch)
tree6f3e90dacad4581b7f1cabe235cca298833a3da4 /src/widgets/kernel
parent109e088c7c5d0c9325966e88d55fd9f7a58f67ea (diff)
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qboxlayout.cpp16
-rw-r--r--src/widgets/kernel/qformlayout.cpp2
-rw-r--r--src/widgets/kernel/qgridlayout.cpp10
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp18
-rw-r--r--src/widgets/kernel/qtooltip.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp8
-rw-r--r--src/widgets/kernel/qwidgetaction.cpp4
-rw-r--r--src/widgets/kernel/qwidgetrepaintmanager.cpp6
8 files changed, 33 insertions, 33 deletions
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index d16d903f53..501883e85a 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -233,7 +233,7 @@ void QBoxLayoutPrivate::setupGeom()
hasHfw = false;
- int n = list.count();
+ int n = list.size();
geomArray.clear();
QList<QLayoutStruct> a(n);
@@ -365,7 +365,7 @@ void QBoxLayoutPrivate::setupGeom()
void QBoxLayoutPrivate::calcHfw(int w)
{
QList<QLayoutStruct> &a = geomArray;
- int n = a.count();
+ int n = a.size();
int h = 0;
int mh = 0;
@@ -411,9 +411,9 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item)
int QBoxLayoutPrivate::validateIndex(int index) const
{
if (index < 0)
- return list.count(); // append
+ return list.size(); // append
- Q_ASSERT_X(index >= 0 && index <= list.count(), "QBoxLayout::insert", "index out of range");
+ Q_ASSERT_X(index >= 0 && index <= list.size(), "QBoxLayout::insert", "index out of range");
return index;
}
@@ -680,7 +680,7 @@ void QBoxLayout::invalidate()
int QBoxLayout::count() const
{
Q_D(const QBoxLayout);
- return d->list.count();
+ return d->list.size();
}
/*!
@@ -689,7 +689,7 @@ int QBoxLayout::count() const
QLayoutItem *QBoxLayout::itemAt(int index) const
{
Q_D(const QBoxLayout);
- return index >= 0 && index < d->list.count() ? d->list.at(index)->item : nullptr;
+ return index >= 0 && index < d->list.size() ? d->list.at(index)->item : nullptr;
}
/*!
@@ -698,7 +698,7 @@ QLayoutItem *QBoxLayout::itemAt(int index) const
QLayoutItem *QBoxLayout::takeAt(int index)
{
Q_D(QBoxLayout);
- if (index < 0 || index >= d->list.count())
+ if (index < 0 || index >= d->list.size())
return nullptr;
QBoxLayoutItem *b = d->list.takeAt(index);
QLayoutItem *item = b->item;
@@ -749,7 +749,7 @@ void QBoxLayout::setGeometry(const QRect &r)
QList<QLayoutStruct> a = d->geomArray;
int pos = horz(d->dir) ? s.x() : s.y();
int space = horz(d->dir) ? s.width() : s.height();
- int n = a.count();
+ int n = a.size();
if (d->hasHfw && !horz(d->dir)) {
for (int i = 0; i < n; i++) {
QBoxLayoutItem *box = d->list.at(i);
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index fdce766c93..e924c71997 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1643,7 +1643,7 @@ void QFormLayout::addItem(QLayoutItem *item)
int QFormLayout::count() const
{
Q_D(const QFormLayout);
- return d->m_things.count();
+ return d->m_things.size();
}
/*!
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index c3fb7d6993..7998567a21 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -109,18 +109,18 @@ public:
int minimumHeightForWidth(int width, int hSpacing, int vSpacing);
inline void getNextPos(int &row, int &col) { row = nextR; col = nextC; }
- inline int count() const { return things.count(); }
+ inline int count() const { return things.size(); }
QRect cellRect(int row, int col) const;
inline QLayoutItem *itemAt(int index) const {
- if (index >= 0 && index < things.count())
+ if (index >= 0 && index < things.size())
return things.at(index)->item();
else
return nullptr;
}
inline QLayoutItem *takeAt(int index) {
Q_Q(QGridLayout);
- if (index >= 0 && index < things.count()) {
+ if (index >= 0 && index < things.size()) {
if (QGridBox *b = things.takeAt(index)) {
QLayoutItem *item = b->takeItem();
if (QLayout *l = item->layout()) {
@@ -148,7 +148,7 @@ public:
}
void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const {
- if (index >= 0 && index < things.count()) {
+ if (index >= 0 && index < things.size()) {
const QGridBox *b = things.at(index);
int toRow = b->toRow(rr);
int toCol = b->toCol(cc);
@@ -1294,7 +1294,7 @@ QLayoutItem *QGridLayout::itemAt(int index) const
QLayoutItem *QGridLayout::itemAtPosition(int row, int column) const
{
Q_D(const QGridLayout);
- int n = d->things.count();
+ int n = d->things.size();
for (int i = 0; i < n; ++i) {
QGridBox *box = d->things.at(i);
if (row >= box->row && row <= box->toRow(d->rr)
diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp
index 78177aa0cd..aca470fe1c 100644
--- a/src/widgets/kernel/qstackedlayout.cpp
+++ b/src/widgets/kernel/qstackedlayout.cpp
@@ -166,7 +166,7 @@ QStackedLayout::~QStackedLayout()
int QStackedLayout::addWidget(QWidget *widget)
{
Q_D(QStackedLayout);
- return insertWidget(d->list.count(), widget);
+ return insertWidget(d->list.size(), widget);
}
/*!
@@ -187,9 +187,9 @@ int QStackedLayout::insertWidget(int index, QWidget *widget)
{
Q_D(QStackedLayout);
addChildWidget(widget);
- index = qMin(index, d->list.count());
+ index = qMin(index, d->list.size());
if (index < 0)
- index = d->list.count();
+ index = d->list.size();
QWidgetItem *wi = QLayoutPrivate::createWidgetItem(this, widget);
d->list.insert(index, wi);
invalidate();
@@ -234,8 +234,8 @@ QLayoutItem *QStackedLayout::takeAt(int index)
QLayoutItem *item = d->list.takeAt(index);
if (index == d->index) {
d->index = -1;
- if ( d->list.count() > 0 ) {
- int newIndex = (index == d->list.count()) ? index-1 : index;
+ if ( d->list.size() > 0 ) {
+ int newIndex = (index == d->list.size()) ? index-1 : index;
setCurrentIndex(newIndex);
} else {
emit currentChanged(-1);
@@ -403,7 +403,7 @@ QSize QStackedLayout::sizeHint() const
{
Q_D(const QStackedLayout);
QSize s(0, 0);
- int n = d->list.count();
+ int n = d->list.size();
for (int i = 0; i < n; ++i)
if (QWidget *widget = d->list.at(i)->widget()) {
@@ -424,7 +424,7 @@ QSize QStackedLayout::minimumSize() const
{
Q_D(const QStackedLayout);
QSize s(0, 0);
- int n = d->list.count();
+ int n = d->list.size();
for (int i = 0; i < n; ++i)
if (QWidget *widget = d->list.at(i)->widget())
@@ -444,7 +444,7 @@ void QStackedLayout::setGeometry(const QRect &rect)
widget->setGeometry(rect);
break;
case StackAll:
- if (const int n = d->list.count())
+ if (const int n = d->list.size())
for (int i = 0; i < n; ++i)
if (QWidget *widget = d->list.at(i)->widget())
widget->setGeometry(rect);
@@ -531,7 +531,7 @@ void QStackedLayout::setStackingMode(StackingMode stackingMode)
return;
d->stackingMode = stackingMode;
- const int n = d->list.count();
+ const int n = d->list.size();
if (n == 0)
return;
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index b831c5265a..3166613199 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -157,7 +157,7 @@ QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int mse
void QTipLabel::restartExpireTimer(int msecDisplayTime)
{
- int time = 10000 + 40 * qMax(0, text().length()-100);
+ int time = 10000 + 40 * qMax(0, text().size()-100);
if (msecDisplayTime > 0)
time = msecDisplayTime;
expireTimer.start(time, this);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 202750d659..aa7b70446b 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -3133,7 +3133,7 @@ void QWidget::addAction(QAction *action)
*/
void QWidget::addActions(const QList<QAction *> &actions)
{
- for(int i = 0; i < actions.count(); i++)
+ for(int i = 0; i < actions.size(); i++)
insertAction(nullptr, actions.at(i));
}
@@ -3182,7 +3182,7 @@ void QWidget::insertAction(QAction *before, QAction *action)
*/
void QWidget::insertActions(QAction *before, const QList<QAction*> &actions)
{
- for(int i = 0; i < actions.count(); ++i)
+ for(int i = 0; i < actions.size(); ++i)
insertAction(before, actions.at(i));
}
@@ -9013,7 +9013,7 @@ bool QWidget::event(QEvent *event)
break;
#if QT_CONFIG(menu)
case Qt::ActionsContextMenu:
- if (d->actions.count()) {
+ if (d->actions.size()) {
QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
nullptr, this);
break;
@@ -9243,7 +9243,7 @@ bool QWidget::event(QEvent *event)
break;
case QEvent::DynamicPropertyChange: {
const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
- if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) {
+ if (propName.size() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) {
uint value = property(propName.constData()).toUInt();
if (!d->extra)
d->createExtra();
diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp
index 1f2fa5dea3..4a3fb2be89 100644
--- a/src/widgets/kernel/qwidgetaction.cpp
+++ b/src/widgets/kernel/qwidgetaction.cpp
@@ -82,7 +82,7 @@ QWidgetAction::QWidgetAction(QObject *parent)
QWidgetAction::~QWidgetAction()
{
Q_D(QWidgetAction);
- for (int i = 0; i < d->createdWidgets.count(); ++i)
+ for (int i = 0; i < d->createdWidgets.size(); ++i)
disconnect(d->createdWidgets.at(i), SIGNAL(destroyed(QObject*)),
this, SLOT(_q_widgetDestroyed(QObject*)));
QList<QWidget *> widgetsToDelete = d->createdWidgets;
@@ -190,7 +190,7 @@ bool QWidgetAction::event(QEvent *event)
if (event->type() == QEvent::ActionChanged) {
if (d->defaultWidget)
d->defaultWidget->setEnabled(isEnabled());
- for (int i = 0; i < d->createdWidgets.count(); ++i)
+ for (int i = 0; i < d->createdWidgets.size(); ++i)
d->createdWidgets.at(i)->setEnabled(isEnabled());
}
return QAction::event(event);
diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp
index 69ab7de1af..02a489c03d 100644
--- a/src/widgets/kernel/qwidgetrepaintmanager.cpp
+++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp
@@ -808,7 +808,7 @@ void QWidgetRepaintManager::paintAndFlush()
// texture content changes. Check if we have such widgets in the special
// dirty list.
QVarLengthArray<QWidget *, 16> paintPending;
- const int numPaintPending = dirtyRenderToTextureWidgets.count();
+ const int numPaintPending = dirtyRenderToTextureWidgets.size();
paintPending.reserve(numPaintPending);
for (int i = 0; i < numPaintPending; ++i) {
QWidget *w = dirtyRenderToTextureWidgets.at(i);
@@ -850,7 +850,7 @@ void QWidgetRepaintManager::paintAndFlush()
}
}
}
- for (int i = 0; i < dirtyRenderToTextureWidgets.count(); ++i)
+ for (int i = 0; i < dirtyRenderToTextureWidgets.size(); ++i)
resetWidget(dirtyRenderToTextureWidgets.at(i));
dirtyRenderToTextureWidgets.clear();
@@ -1133,7 +1133,7 @@ QRegion QWidgetRepaintManager::staticContents(QWidget *parent, const QRect &with
return region;
const bool clipToRect = !withinClipRect.isEmpty();
- const int count = staticWidgets.count();
+ const int count = staticWidgets.size();
for (int i = 0; i < count; ++i) {
QWidget *w = staticWidgets.at(i);
QWidgetPrivate *wd = w->d_func();