void QQuickLoaderPrivate::setInitialState(QObject *obj) { Q_Q(QQuickLoader); QQuickItem *item = qmlobject_cast<QQuickItem*>(obj); if (item) { // If the item doesn't have an explicit size, but the Loader // does, then set the item's size now before bindings are // evaluated, otherwise we will end up resizing the item // later and triggering any affected bindings/anchors. if (widthValid && !QQuickItemPrivate::get(item)->widthValid) item->setWidth(q->width()); if (heightValid && !QQuickItemPrivate::get(item)->heightValid) item->setHeight(q->height()); item->setParentItem(q); } if (obj) { QQml_setParent_noEvent(itemContext, obj); QQml_setParent_noEvent(obj, q); itemContext = 0; } if (initialPropertyValues.isUndefined()) return; QQmlComponentPrivate *d = QQmlComponentPrivate::get(component); Q_ASSERT(d && d->engine); QV4::ExecutionEngine *v4 = qmlGlobalForIpv.engine(); Q_ASSERT(v4); QV4::Scope scope(v4); QV4::ScopedValue ipv(scope, initialPropertyValues.value()); d->initializeObjectWithInitialProperties(qmlGlobalForIpv, ipv, obj); }
QT_BEGIN_NAMESPACE QQuickItem *QQuickTextUtil::createCursor( QQmlComponent *component, QQuickItem *parent, const QRectF &rectangle, const char *className) { QQuickItem *item = 0; if (component->isReady()) { QQmlContext *creationContext = component->creationContext(); if (QObject *object = component->beginCreate(creationContext ? creationContext : qmlContext(parent))) { if ((item = qobject_cast<QQuickItem *>(object))) { QQml_setParent_noEvent(item, parent); item->setParentItem(parent); item->setPosition(rectangle.topLeft()); item->setHeight(rectangle.height()); } else { qmlInfo(parent) << tr("%1 does not support loading non-visual cursor delegates.") .arg(QString::fromUtf8(className)); } component->completeCreate(); return item; } } else if (component->isLoading()) { QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)), parent, SLOT(createCursor()), Qt::UniqueConnection); return item; } qmlInfo(parent, component->errors()) << tr("Could not load cursor delegate"); return item; }
void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state, bool ignoreTrans) { Q_Q(QQuickStateGroup); if (!componentComplete) { currentState = state; return; } if (applyingState) { qmlInfo(q) << "Can't apply a state change as part of a state definition."; return; } applyingState = true; QQuickTransition *transition = ignoreTrans ? 0 : findTransition(currentState, state); if (stateChangeDebug()) { qWarning() << this << "Changing state. From" << currentState << ". To" << state; if (transition) qWarning() << " using transition" << transition->fromState() << transition->toState(); } QQuickState *oldState = 0; if (!currentState.isEmpty()) { for (int ii = 0; ii < states.count(); ++ii) { if (states.at(ii)->name() == currentState) { oldState = states.at(ii); break; } } } currentState = state; emit q->stateChanged(currentState); QQuickState *newState = 0; for (int ii = 0; ii < states.count(); ++ii) { if (states.at(ii)->name() == currentState) { newState = states.at(ii); break; } } if (oldState == 0 || newState == 0) { if (!nullState) { nullState = new QQuickState; QQml_setParent_noEvent(nullState, q); nullState->setStateGroup(q); } if (!oldState) oldState = nullState; if (!newState) newState = nullState; } newState->apply(transition, oldState); applyingState = false; //### consider removing this (don't allow state changes in transition) }