102void QQuickPanePrivate::init()
105 q->setFlag(QQuickItem::ItemIsFocusScope);
106 q->setAcceptedMouseButtons(Qt::AllButtons);
108 q->setCursor(Qt::ArrowCursor);
110 connect(q, &QQuickControl::implicitContentWidthChanged,
this, &QQuickPanePrivate::updateContentWidth);
111 connect(q, &QQuickControl::implicitContentHeightChanged,
this, &QQuickPanePrivate::updateContentHeight);
112 setSizePolicy(QLayoutPolicy::Preferred, QLayoutPolicy::Preferred);
157void QQuickPanePrivate::contentChildrenChange()
161 QQuickItem *newFirstChild = getFirstChild();
163 if (newFirstChild != firstChild) {
165 removeImplicitSizeListener(firstChild);
166 if (newFirstChild && newFirstChild != contentItem)
167 addImplicitSizeListener(newFirstChild);
168 firstChild = newFirstChild;
171 updateImplicitContentSize();
172 emit q->contentChildrenChanged();
175qreal QQuickPanePrivate::getContentWidth()
const
183 const qreal cw = contentItem->implicitWidth();
184 if (!qFuzzyIsNull(cw))
187 const auto contentChildren = contentChildItems();
188 if (contentChildren.size() == 1)
189 return contentChildren.first()->implicitWidth();
204qreal QQuickPanePrivate::getContentHeight()
const
209 if (hasContentHeight)
210 return contentHeight;
212 const qreal ch = contentItem->implicitHeight();
213 if (!qFuzzyIsNull(ch))
216 const auto contentChildren = contentChildItems();
217 if (contentChildren.size() == 1)
218 return contentChildren.first()->implicitHeight();
223void QQuickPanePrivate::updateContentWidth()
226 if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
229 const qreal oldContentWidth = contentWidth;
230 contentWidth = implicitContentWidth;
231 qCDebug(lcPane) <<
"contentWidth of" << q <<
"changed to" << contentWidth;
232 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(oldContentWidth, contentHeight));
233 emit q->contentWidthChanged();
236void QQuickPanePrivate::updateContentHeight()
239 if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
242 const qreal oldContentHeight = contentHeight;
243 contentHeight = implicitContentHeight;
244 qCDebug(lcPane) <<
"contentHeight of" << q <<
"changed to" << contentHeight;
245 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(contentWidth, oldContentHeight));
246 emit q->contentHeightChanged();
266QQuickPane::~QQuickPane()
269 if (d->contentItem) {
272 QObjectPrivate::disconnect(d->contentItem, &QQuickItem::childrenChanged,
273 d, &QQuickPanePrivate::contentChildrenChange);
275 d->removeImplicitSizeListener(d->contentItem);
276 d->removeImplicitSizeListener(d->firstChild);
302void QQuickPane::setContentWidth(qreal width)
305 d->hasContentWidth =
true;
306 if (qFuzzyCompare(d->contentWidth, width))
309 const qreal oldWidth = d->contentWidth;
310 d->contentWidth = width;
311 contentSizeChange(QSizeF(width, d->contentHeight), QSizeF(oldWidth, d->contentHeight));
312 emit contentWidthChanged();
341void QQuickPane::setContentHeight(qreal height)
344 d->hasContentHeight =
true;
345 if (qFuzzyCompare(d->contentHeight, height))
348 const qreal oldHeight = d->contentHeight;
349 d->contentHeight = height;
350 contentSizeChange(QSizeF(d->contentWidth, height), QSizeF(d->contentWidth, oldHeight));
351 emit contentHeightChanged();
378QQmlListProperty<QObject> QQuickPanePrivate::contentData()
381 return QQmlListProperty<QObject>(q->contentItem(),
nullptr,
382 QQuickItemPrivate::data_append,
383 QQuickItemPrivate::data_count,
384 QQuickItemPrivate::data_at,
385 QQuickItemPrivate::data_clear);
401QQmlListProperty<QQuickItem> QQuickPanePrivate::contentChildren()
404 return QQmlListProperty<QQuickItem>(q->contentItem(),
nullptr,
405 QQuickItemPrivate::children_append,
406 QQuickItemPrivate::children_count,
407 QQuickItemPrivate::children_at,
408 QQuickItemPrivate::children_clear);
418void QQuickPane::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
421 QQuickControl::contentItemChange(newItem, oldItem);
423 d->removeImplicitSizeListener(oldItem);
424 QObjectPrivate::disconnect(oldItem, &QQuickItem::childrenChanged, d, &QQuickPanePrivate::contentChildrenChange);
427 d->addImplicitSizeListener(newItem);
428 QObjectPrivate::connect(newItem, &QQuickItem::childrenChanged, d, &QQuickPanePrivate::contentChildrenChange);
430 d->contentChildrenChange();