95 if (attachedData->getControllingProxy() ==
this) {
97 d->target->setParentItem(
nullptr);
99 attachedData->releaseProxy(
this);
115 const QSizeF sz = newGeom.size();
120 if (attachedData->getControllingProxy() !=
this)
126 if (
t->parentItem() !=
this)
127 pos =
t->parentItem()->mapFromGlobal(mapToGlobal(0, 0));
129 if (
t->size() == sz &&
t->position() ==
pos && newGeom == oldGeom)
156#define propertyForwarding(property, Property) \
157 void QQuickLayoutItemProxy::target##Property##Changed() { \
158 Q_D(QQuickLayoutItemProxy); \
159 QQuickLayoutAttached *attTarget = attachedLayoutObject(target(), false); \
160 QQuickLayoutAttached *attProxy = attachedLayoutObject(this, false); \
161 if (!attTarget) return; \
162 if (attProxy->property() == attTarget->property()) \
164 d->m_expectProxy##Property##Change = true; \
165 attProxy->set##Property(attTarget->property()); \
167 void QQuickLayoutItemProxy::proxy##Property##Changed() { \
168 Q_D(QQuickLayoutItemProxy); \
169 if (d->m_expectProxy##Property##Change) { \
170 d->m_expectProxy##Property##Change = false; \
173 QQuickLayoutAttached *attTarget = attachedLayoutObject(target(), false); \
174 if (!attTarget) return; \
175 disconnect(attTarget, &QQuickLayoutAttached::property##Changed, this, &QQuickLayoutItemProxy::target##Property##Changed); \
195#undef propertyForwarding
226 if (newTarget ==
d->target)
229 d->target = newTarget;
234 if (newTarget->
property(
"QQuickLayoutItemProxyAttachedData").
isValid()) {
240 newTarget->
setProperty(
"QQuickLayoutItemProxyAttachedData",
v);
242 attachedData->registerProxy(
this);
245 if (!attachedData->proxyHasControl())
253 disconnect(attTarget,
nullptr, attProxy,
nullptr);
257#define connectPropertyForwarding(property, Property) \
258 if (!attProxy->is##Property##Set()) { \
259 connect(attTarget, &QQuickLayoutAttached::property##Changed, this, &QQuickLayoutItemProxy::target##Property##Changed); \
260 connect(attProxy, &QQuickLayoutAttached::property##Changed, this, &QQuickLayoutItemProxy::proxy##Property##Changed); \
261 target##Property##Changed(); \
279#undef connectPropertyForwarding
296 emit targetChanged();
309 return (attachedData->getControllingProxy() ==
this) ?
target() :
nullptr;
339 if (
isVisible() && attachedData->getControllingProxy() !=
this) {
340 if (attachedData->takeControl(
this)) {
341 d->target->setVisible(
true);
342 d->target->setParentItem(
this);
346 if (!
isVisible() && attachedData->getControllingProxy() ==
this){
347 if (
d->target->parentItem() ==
this) {
348 d->target->setParentItem(
nullptr);
350 qCDebug(lcLayouts) <<
"Parent was changed to" <<
d->target->parentItem() <<
"while an ItemProxy had control";
351 d->target->setVisible(
false);
352 attachedData->releaseControl(
this);
366 if (attachedData->getControllingProxy() ==
this)
374 m_expectProxyMinimumWidthChange(
false),
375 m_expectProxyMinimumHeightChange(
false),
376 m_expectProxyPreferredWidthChange(
false),
377 m_expectProxyPreferredHeightChange(
false),
378 m_expectProxyMaximumWidthChange(
false),
379 m_expectProxyMaximumHeightChange(
false),
380 m_expectProxyFillWidthChange(
false),
381 m_expectProxyFillHeightChange(
false),
382 m_expectProxyAlignmentChange(
false),
383 m_expectProxyHorizontalStretchFactorChange(
false),
384 m_expectProxyVerticalStretchFactorChange(
false),
385 m_expectProxyMarginsChange(
false),
386 m_expectProxyLeftMarginChange(
false),
387 m_expectProxyTopMarginChange(
false),
388 m_expectProxyRightMarginChange(
false),
389 m_expectProxyBottomMarginChange(
false)
414 proxy->clearTarget();
465 <<
"takes control of"
486 <<
"no longer controls"
493 for (
auto &otherProxy: std::as_const(
proxies)) {
494 if (
proxy != otherProxy)
495 otherProxy->maybeTakeControl();
516 using Property = QQmlListProperty<Type>;
520 [](Property *
p) {
return static_cast<QList<Type *> *
>(
p->data)->
size(); },
521 [](Property *
p,
qsizetype i) {
return static_cast<QList<Type *> *
>(
p->data)->
at(
i); }
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
void deleteLater()
\threadsafe
\inmodule QtCore\reentrant
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
void implicitWidthChanged()
void implicitHeightChanged()
virtual QRectF boundingRect() const
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
void setImplicitHeight(qreal)
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
void setImplicitWidth(qreal)
Provides attached properties for items that are managed by one or more LayoutItemProxy.
QQmlListProperty< QQuickLayoutItemProxy > getProxies()
QQuickLayoutItemProxyAttachedData::getProxies.
QML_ANONYMOUSbool proxyHasControl
void controllingProxyChanged()
QQuickLayoutItemProxyAttachedData(QObject *parent)
void registerProxy(QQuickLayoutItemProxy *proxy)
QQuickLayoutItemProxyAttachedData::registerProxy registers a proxy that manages the item this data is...
void releaseControl(QQuickLayoutItemProxy *proxy)
QQuickLayoutItemProxyAttachedData::releaseControl is called by LayoutItemProxies when they try no lon...
~QQuickLayoutItemProxyAttachedData() override
QQuickLayoutItemProxy * controllingProxy
bool takeControl(QQuickLayoutItemProxy *proxy)
QQuickLayoutItemProxyAttachedData::takeControl is called by LayoutItemProxies when they try to take c...
void releaseProxy(QQuickLayoutItemProxy *proxy)
QQuickLayoutItemProxyAttachedData::releaseProxy removes a proxy from a list of known proxies that man...
QQmlListProperty< QQuickLayoutItemProxy > proxies
QQuickLayoutItemProxy * getControllingProxy() const
QQuickLayoutItemProxyAttachedData::getControllingProxy.
QQuickLayoutItemProxyPrivate()
void clearTarget()
QQuickLayoutItemProxy::clearTarget sets the target to null.
void setTarget(QQuickItem *newTarget)
QQuickLayoutItemProxy::setTarget sets the target.
void geometryChange(const QRectF &newGeom, const QRectF &oldGeom) override
QQuickLayoutItemProxy::geometryChange Reimplementation of QQuickItem::geometryChange to update the ta...
void itemChange(ItemChange c, const ItemChangeData &d) override
QQuickLayoutItemProxy::itemChange is a reimplementation of QQuickItem::itemChange to react to changes...
void maybeTakeControl()
QQuickLayoutItemProxy::maybeTakeControl checks and takes over control of the item.
void updatePos()
QQuickLayoutItemProxy::updatePos sets the geometry of the target to the geometry of the proxy.
~QQuickLayoutItemProxy() override
Q_INVOKABLE QQuickItem * effectiveTarget() const
QQuickLayoutItemProxy::effectiveTarget.
\inmodule QtCore\reentrant
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
void setValue(T &&avalue)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
QQuickLayoutAttached * attachedLayoutObject(QQuickItem *item, bool create=true)
#define connectPropertyForwarding(property, Property)
#define propertyForwarding(property, Property)
myObject disconnect()
[26]