8#include <private/qqmlbinding_p.h>
9#include <private/qqmlglobal_p.h>
11#include <QtCore/qstringlist.h>
12#include <QtCore/qdebug.h>
13#include <QtCore/qvector.h>
15#include <private/qobject_p.h>
99 state->setStateGroup(
nullptr);
102 d->nullState->setStateGroup(
nullptr);
134 return QQmlListProperty<QQuickState>(
this, &
d->states,
148 state->setStateGroup(_this);
154 return _this->d_func()->
states.size();
166 d->setCurrentStateInternal(
QString(),
true);
169 state->setStateGroup(
nullptr);
177 auto *
d = self->d_func();
178 auto *oldState =
d->states.
at(
index);
179 if (oldState !=
state) {
181 oldState->setStateGroup(
nullptr);
184 state->setStateGroup(self);
186 if (!oldState ||
d->currentState == oldState->name())
195 if (
d->currentState == last->name()) {
201 d->states.removeLast();
284 return d->currentState;
290 if (
d->currentState ==
state)
293 d->setCurrentStateInternal(
state);
299 d->componentComplete =
false;
305 d->componentComplete =
true;
307 QVarLengthArray<QString, 4>
names;
308 names.reserve(
d->states.size());
313 if (!
state->isNamed())
317 if (
names.contains(stateName))
318 qmlWarning(
state->parent()) <<
"Found duplicate state name: " << stateName;
323 if (
d->updateAutoState()) {
325 }
else if (!
d->currentState.isEmpty()) {
327 d->currentState.clear();
328 d->setCurrentStateInternal(cs,
true);
335bool QQuickStateGroup::updateAutoState()
338 return d->updateAutoState();
352 bool whenValue =
state->when();
355 Q_ASSERT(!potentialWhenBinding.isUntypedPropertyBinding());
363 const auto boolType = QMetaType::fromType<bool>();
364 const bool isUndefined = !binding->
evaluate(&whenValue, boolType);
371 qCDebug(lcStates) <<
"Setting auto state due to expression";
373 q->setState(
state->name());
395 bool reversed =
false;
402 for (
int ii = 0; ii < 2; ++ii)
404 if (ii && (!
t->reversible() ||
408 const QString fromStateStr =
t->fromState();
409 const QString toStateStr =
t->toState();
412 for (
int jj = 0; jj < fromState.size(); ++jj)
413 fromState[jj] = fromState.at(jj).trimmed();
415 for (
int jj = 0; jj < toState.size(); ++jj)
416 toState[jj] = toState.at(jj).trimmed();
418 qSwap(fromState, toState);
423 else if (fromState.contains(
QStringView(asterisk)))
444 }
else if (tScore > score) {
452 highest->setReversed(reversed);
467 qmlWarning(
q) <<
"Can't apply a state change as part of a state definition.";
474 if (lcStates().isDebugEnabled()) {
502 if (oldState ==
nullptr ||
newState ==
nullptr) {
530 d->states.removeOne(
state);
533void QQuickStateGroup::stateAboutToComplete()
536 d->applyingState =
false;
542#include "moc_qquickstategroup_p.cpp"
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
static QQmlAnyBinding ofProperty(const QQmlProperty &prop)
bool hasValidContext() const
static qsizetype count_transitions(QQmlListProperty< QQuickTransition > *list)
QList< QQuickTransition * > transitions
static void clear_states(QQmlListProperty< QQuickState > *list)
static void replace_states(QQmlListProperty< QQuickState > *list, qsizetype index, QQuickState *state)
static void removeLast_states(QQmlListProperty< QQuickState > *list)
void setCurrentStateInternal(const QString &state, bool=false)
QQuickStateGroupPrivate()
static QQuickTransition * at_transition(QQmlListProperty< QQuickTransition > *list, qsizetype index)
static QQuickState * at_state(QQmlListProperty< QQuickState > *list, qsizetype index)
static void clear_transitions(QQmlListProperty< QQuickTransition > *list)
static void append_transition(QQmlListProperty< QQuickTransition > *list, QQuickTransition *state)
QQuickTransition * findTransition(const QString &from, const QString &to)
static qsizetype count_state(QQmlListProperty< QQuickState > *list)
static void append_state(QQmlListProperty< QQuickState > *list, QQuickState *state)
QList< QQuickState * > states
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void removeState(QQuickState *state)
QQmlListProperty< QQuickTransition > transitionsProperty()
\qmlproperty list<Transition> QtQuick::StateGroup::transitions This property holds a list of transiti...
QQuickStateGroup(QObject *=nullptr)
\qmltype StateGroup \instantiates QQuickStateGroup \inqmlmodule QtQuick
QQuickState * findState(const QString &name) const
QQmlListProperty< QQuickState > states
void setState(const QString &)
QQmlListProperty< QQuickState > statesProperty()
\qmlproperty list<State> QtQuick::StateGroup::states This property holds a list of states defined by ...
virtual ~QQuickStateGroup()
void classBegin() override
Invoked after class creation, but before any properties have been set.
QQmlListProperty< QQuickTransition > transitions
void apply(QQuickTransition *, QQuickState *revert)
void setStateGroup(QQuickStateGroup *)
QString fromState() const
\qmlproperty string QtQuick::Transition::from \qmlproperty string QtQuick::Transition::to
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
#define qCDebug(category,...)
GLdouble GLdouble GLdouble GLdouble q
void QQml_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define QStringLiteral(str)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
\inmodule QtCore \reentrant