From 2a4ff847e8c018f31b14ecffd229d3793138ab1b Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 29 Jun 2021 12:09:17 +0200 Subject: Adjust to QQuickItemPrivate::{width,height}Valid becoming a function Task-number: QTBUG-94703 Pick-to: 6.2 Change-Id: I2c48f1cc94b8dd94cddab1d833f62299d35fe5d9 Reviewed-by: Mitch Curtis Reviewed-by: Andrei Golubev --- .../qquickfolderbreadcrumbbar.cpp | 2 +- src/quicktemplates2/qquickapplicationwindow.cpp | 12 +++++----- src/quicktemplates2/qquickcontrol.cpp | 14 ++++++------ src/quicktemplates2/qquickdialogbuttonbox.cpp | 4 ++-- src/quicktemplates2/qquicklabel.cpp | 14 ++++++------ src/quicktemplates2/qquickmenu.cpp | 4 ++-- src/quicktemplates2/qquickstackelement.cpp | 4 ++-- src/quicktemplates2/qquickswipedelegate.cpp | 4 ++-- src/quicktemplates2/qquicktabbar.cpp | 12 +++++----- src/quicktemplates2/qquicktextarea.cpp | 14 ++++++------ src/quicktemplates2/qquicktextfield.cpp | 26 +++++++++++----------- 11 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp index fa7ebb83..c204d8fa 100644 --- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp +++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp @@ -448,7 +448,7 @@ qreal QQuickFolderBreadcrumbBarPrivate::getContentWidth() const QQuickItem *item = q->itemAt(i); if (item) { QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) + if (!p->widthValid()) totalWidth += item->implicitWidth(); else totalWidth += item->width(); diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index bf309389..eb1d12c9 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -191,9 +191,9 @@ static void layoutItem(QQuickItem *item, qreal y, qreal width) item->setY(y); QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) { + if (!p->widthValid()) { item->setWidth(width); - p->widthValid = false; + p->widthValidFlag = false; } } @@ -219,13 +219,13 @@ void QQuickApplicationWindowPrivate::relayout() if (background) { QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (!p->widthValid && qFuzzyIsNull(background->x())) { + if (!p->widthValid() && qFuzzyIsNull(background->x())) { background->setWidth(q->width()); - p->widthValid = false; + p->widthValidFlag = false; } - if (!p->heightValid && qFuzzyIsNull(background->y())) { + if (!p->heightValid() && qFuzzyIsNull(background->y())) { background->setHeight(q->height()); - p->heightValid = false; + p->heightValidFlag = false; } } } diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 56e7e935..072b6f4c 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -381,12 +381,12 @@ void QQuickControlPrivate::resizeBackground() resizingBackground = true; QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) + if (((!p->widthValid() || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) || (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) { background->setX(getLeftInset()); background->setWidth(width - getLeftInset() - getRightInset()); } - if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + if (((!p->heightValid() || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) { background->setY(getTopInset()); background->setHeight(height - getTopInset() - getBottomInset()); @@ -833,9 +833,9 @@ void QQuickControlPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryC // Only set hasBackgroundWidth/Height if it was a width/height change, // otherwise we're prevented from setting a width/height in the future. if (change.widthChange()) - extra.value().hasBackgroundWidth = p->widthValid; + extra.value().hasBackgroundWidth = p->widthValid(); if (change.heightChange()) - extra.value().hasBackgroundHeight = p->heightValid; + extra.value().hasBackgroundHeight = p->heightValid(); resizeBackground(); } @@ -1531,9 +1531,9 @@ void QQuickControl::setBackground(QQuickItem *background) if (qFuzzyIsNull(background->z())) background->setZ(-1); QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; + if (p->widthValid() || p->heightValid()) { + d->extra.value().hasBackgroundWidth = p->widthValid(); + d->extra.value().hasBackgroundHeight = p->heightValid(); } if (isComponentComplete()) d->resizeBackground(); diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index b6b9ed84..a4b3313b 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -266,7 +266,7 @@ void QQuickDialogButtonBoxPrivate::updateLayout() QQuickItem *item = q->itemAt(i); if (item) { QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) { + if (!p->widthValid()) { if (!halign) item->setWidth(itemWidth); else @@ -275,7 +275,7 @@ void QQuickDialogButtonBoxPrivate::updateLayout() item->setHeight(contentHeight); else item->resetHeight(); - p->widthValid = false; + p->widthValidFlag = false; } } buttons += static_cast(item); diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 2cf3be16..d5d9146a 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -149,12 +149,12 @@ void QQuickLabelPrivate::resizeBackground() resizingBackground = true; QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) + if (((!p->widthValid() || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) || (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) { background->setX(getLeftInset()); background->setWidth(width - getLeftInset() - getRightInset()); } - if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + if (((!p->heightValid() || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) { background->setY(getTopInset()); background->setHeight(height - getTopInset() - getBottomInset()); @@ -271,8 +271,8 @@ void QQuickLabelPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryCha return; QQuickItemPrivate *p = QQuickItemPrivate::get(item); - extra.value().hasBackgroundWidth = p->widthValid; - extra.value().hasBackgroundHeight = p->heightValid; + extra.value().hasBackgroundWidth = p->widthValid(); + extra.value().hasBackgroundHeight = p->heightValid(); resizeBackground(); } @@ -378,9 +378,9 @@ void QQuickLabel::setBackground(QQuickItem *background) if (qFuzzyIsNull(background->z())) background->setZ(-1); QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; + if (p->widthValid() || p->heightValid()) { + d->extra.value().hasBackgroundWidth = p->widthValid(); + d->extra.value().hasBackgroundHeight = p->heightValid(); } if (isComponentComplete()) d->resizeBackground(); diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 561e1037..887f802c 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -337,9 +337,9 @@ void QQuickMenuPrivate::resizeItem(QQuickItem *item) return; QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) { + if (!p->widthValid()) { item->setWidth(contentItem->width()); - p->widthValid = false; + p->widthValidFlag = false; } } diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp index 1b4ac476..b275f96b 100644 --- a/src/quicktemplates2/qquickstackelement.cpp +++ b/src/quicktemplates2/qquickstackelement.cpp @@ -194,9 +194,9 @@ void QQuickStackElement::initialize() return; QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!(widthValid = p->widthValid)) + if (!(widthValid = p->widthValid())) item->setWidth(view->width()); - if (!(heightValid = p->heightValid)) + if (!(heightValid = p->heightValid())) item->setHeight(view->height()); item->setParentItem(view); p->addItemChangeListener(this, QQuickItemPrivate::Destroyed); diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 5e208fb9..817704ba 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -731,11 +731,11 @@ void QQuickSwipeDelegatePrivate::resizeBackground() QQuickItemPrivate *p = QQuickItemPrivate::get(background); const bool extraAllocated = extra.isAllocated(); // Don't check for or set the x here since it will just be overwritten by reposition(). - if (((!p->widthValid || !extraAllocated || !extra->hasBackgroundWidth)) + if (((!p->widthValid() || !extraAllocated || !extra->hasBackgroundWidth)) || (extraAllocated && (extra->hasLeftInset || extra->hasRightInset))) { background->setWidth(width - getLeftInset() - getRightInset()); } - if (((!p->heightValid || !extraAllocated || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + if (((!p->heightValid() || !extraAllocated || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extraAllocated && (extra->hasTopInset || extra->hasBottomInset))) { background->setY(getTopInset()); background->setHeight(height - getTopInset() - getBottomInset()); diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp index b38699df..f8810581 100644 --- a/src/quicktemplates2/qquicktabbar.cpp +++ b/src/quicktemplates2/qquicktabbar.cpp @@ -165,7 +165,7 @@ void QQuickTabBarPrivate::updateLayout() QQuickItem *item = q->itemAt(i); if (item) { QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) + if (!p->widthValid()) ++resizableCount; else reservedWidth += item->width(); @@ -179,13 +179,13 @@ void QQuickTabBarPrivate::updateLayout() updatingLayout = true; for (QQuickItem *item : qAsConst(allItems)) { QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) { + if (!p->widthValid()) { item->setWidth(itemWidth); - p->widthValid = false; + p->widthValidFlag = false; } - if (!p->heightValid) { + if (!p->heightValid()) { item->setHeight(contentHeight); - p->heightValid = false; + p->heightValidFlag = false; } else { item->setY((contentHeight - item->height()) / 2); } @@ -202,7 +202,7 @@ qreal QQuickTabBarPrivate::getContentWidth() const QQuickItem *item = q->itemAt(i); if (item) { QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) + if (!p->widthValid()) totalWidth += item->implicitWidth(); else totalWidth += item->width(); diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 183c929e..f1ea24d8 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -226,14 +226,14 @@ void QQuickTextAreaPrivate::resizeBackground() const auto flickable = qobject_cast(background->parentItem()); QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) + if (((!p->widthValid() || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) || (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) { const qreal bgWidth = flickable ? flickable->width() : width; background->setX(getLeftInset()); background->setWidth(bgWidth - getLeftInset() - getRightInset()); } - if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + if (((!p->heightValid() || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) { const qreal bgHeight = flickable ? flickable->height() : height; background->setY(getTopInset()); @@ -416,9 +416,9 @@ void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometry // Only set hasBackgroundWidth/Height if it was a width/height change, // otherwise we're prevented from setting a width/height in the future. if (change.widthChange()) - extra.value().hasBackgroundWidth = p->widthValid; + extra.value().hasBackgroundWidth = p->widthValid(); if (change.heightChange()) - extra.value().hasBackgroundHeight = p->heightValid; + extra.value().hasBackgroundHeight = p->heightValid(); } if (flickable) @@ -617,9 +617,9 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (background) { QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; + if (p->widthValid() || p->heightValid()) { + d->extra.value().hasBackgroundWidth = p->widthValid(); + d->extra.value().hasBackgroundHeight = p->heightValid(); } if (d->flickable) background->setParentItem(d->flickable); diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 06cbd5a2..32e447d7 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -184,22 +184,22 @@ void QQuickTextFieldPrivate::resizeBackground() resizingBackground = true; QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) + if (((!p->widthValid() || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) || (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) { - const bool wasWidthValid = p->widthValid; + const bool wasWidthValid = p->widthValid(); background->setX(getLeftInset()); background->setWidth(width - getLeftInset() - getRightInset()); // If the user hadn't previously set the width, that shouldn't change when we set it for them. if (!wasWidthValid) - p->widthValid = false; + p->widthValidFlag = false; } - if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + if (((!p->heightValid() || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) { - const bool wasHeightValid = p->heightValid; + const bool wasHeightValid = p->heightValid(); background->setY(getTopInset()); background->setHeight(height - getTopInset() - getBottomInset()); if (!wasHeightValid) - p->heightValid = false; + p->heightValidFlag = false; } resizingBackground = false; @@ -361,10 +361,10 @@ void QQuickTextFieldPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometr // QTBUG-71875: only allocate the extra data if we have to. // resizeBackground() relies on the value of extra.isAllocated() // as part of its checks to see whether it should resize the background or not. - if (p->widthValid || extra.isAllocated()) - extra.value().hasBackgroundWidth = p->widthValid; - if (p->heightValid || extra.isAllocated()) - extra.value().hasBackgroundHeight = p->heightValid; + if (p->widthValid() || extra.isAllocated()) + extra.value().hasBackgroundWidth = p->widthValid(); + if (p->heightValid() || extra.isAllocated()) + extra.value().hasBackgroundHeight = p->heightValid(); resizeBackground(); } @@ -476,9 +476,9 @@ void QQuickTextField::setBackground(QQuickItem *background) if (qFuzzyIsNull(background->z())) background->setZ(-1); QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; + if (p->widthValid() || p->heightValid()) { + d->extra.value().hasBackgroundWidth = p->widthValid(); + d->extra.value().hasBackgroundHeight = p->heightValid(); } if (isComponentComplete()) d->resizeBackground(); -- cgit v1.2.3