103void QQuickPanePrivate::init()
106 q->setFlag(QQuickItem::ItemIsFocusScope);
107 q->setAcceptedMouseButtons(Qt::AllButtons);
109 q->setCursor(Qt::ArrowCursor);
111 connect(q, &QQuickControl::implicitContentWidthChanged,
this, &QQuickPanePrivate::updateContentWidth);
112 connect(q, &QQuickControl::implicitContentHeightChanged,
this, &QQuickPanePrivate::updateContentHeight);
113 setSizePolicy(QLayoutPolicy::Preferred, QLayoutPolicy::Preferred);
158void QQuickPanePrivate::contentChildrenChange()
162 QQuickItem *newFirstChild = getFirstChild();
164 if (newFirstChild != firstChild) {
166 removeImplicitSizeListener(firstChild);
167 if (newFirstChild && newFirstChild != contentItem)
168 addImplicitSizeListener(newFirstChild);
169 firstChild = newFirstChild;
172 updateImplicitContentSize();
173 emit q->contentChildrenChanged();
176qreal QQuickPanePrivate::getContentWidth()
const
184 const qreal cw = contentItem->implicitWidth();
185 if (!qFuzzyIsNull(cw))
188 const auto contentChildren = contentChildItems();
189 if (contentChildren.size() == 1)
190 return contentChildren.first()->implicitWidth();
205qreal QQuickPanePrivate::getContentHeight()
const
210 if (hasContentHeight)
211 return contentHeight;
213 const qreal ch = contentItem->implicitHeight();
214 if (!qFuzzyIsNull(ch))
217 const auto contentChildren = contentChildItems();
218 if (contentChildren.size() == 1)
219 return contentChildren.first()->implicitHeight();
224void QQuickPanePrivate::updateContentWidth()
227 if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
230 const qreal oldContentWidth = contentWidth;
231 contentWidth = implicitContentWidth;
232 qCDebug(lcPane) <<
"contentWidth of" << q <<
"changed to" << contentWidth;
233 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(oldContentWidth, contentHeight));
234 emit q->contentWidthChanged();
237void QQuickPanePrivate::updateContentHeight()
240 if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
243 const qreal oldContentHeight = contentHeight;
244 contentHeight = implicitContentHeight;
245 qCDebug(lcPane) <<
"contentHeight of" << q <<
"changed to" << contentHeight;
246 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(contentWidth, oldContentHeight));
247 emit q->contentHeightChanged();
267QQuickPane::~QQuickPane()
270 if (d->contentItem) {
273 QObjectPrivate::disconnect(d->contentItem, &QQuickItem::childrenChanged,
274 d, &QQuickPanePrivate::contentChildrenChange);
276 d->removeImplicitSizeListener(d->contentItem);
277 d->removeImplicitSizeListener(d->firstChild);
303void QQuickPane::setContentWidth(qreal width)
306 d->hasContentWidth =
true;
307 if (qFuzzyCompare(d->contentWidth, width))
310 const qreal oldWidth = d->contentWidth;
311 d->contentWidth = width;
312 contentSizeChange(QSizeF(width, d->contentHeight), QSizeF(oldWidth, d->contentHeight));
313 emit contentWidthChanged();
342void QQuickPane::setContentHeight(qreal height)
345 d->hasContentHeight =
true;
346 if (qFuzzyCompare(d->contentHeight, height))
349 const qreal oldHeight = d->contentHeight;
350 d->contentHeight = height;
351 contentSizeChange(QSizeF(d->contentWidth, height), QSizeF(d->contentWidth, oldHeight));
352 emit contentHeightChanged();
379QQmlListProperty<QObject> QQuickPanePrivate::contentData()
382 return QQmlListProperty<QObject>(q->contentItem(),
nullptr,
383 QQuickItemPrivate::data_append,
384 QQuickItemPrivate::data_count,
385 QQuickItemPrivate::data_at,
386 QQuickItemPrivate::data_clear);
402QQmlListProperty<QQuickItem> QQuickPanePrivate::contentChildren()
405 return QQmlListProperty<QQuickItem>(q->contentItem(),
nullptr,
406 QQuickItemPrivate::children_append,
407 QQuickItemPrivate::children_count,
408 QQuickItemPrivate::children_at,
409 QQuickItemPrivate::children_clear);
419void QQuickPane::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
422 QQuickControl::contentItemChange(newItem, oldItem);
424 d->removeImplicitSizeListener(oldItem);
425 QObjectPrivate::disconnect(oldItem, &QQuickItem::childrenChanged, d, &QQuickPanePrivate::contentChildrenChange);
428 d->addImplicitSizeListener(newItem);
429 QObjectPrivate::connect(newItem, &QQuickItem::childrenChanged, d, &QQuickPanePrivate::contentChildrenChange);
431 d->contentChildrenChange();