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>
29 : nullState(
nullptr), componentComplete(true),
30 ignoreTrans(
false), applyingState(
false), unnamedCount(0) {}
56 void setCurrentStateInternal(
const QString &
state,
bool =
false);
57 bool updateAutoState();
99 for (
int i = 0;
i <
d->states.size(); ++
i) {
101 d->states.at(
i)->setStateGroup(
nullptr);
104 d->nullState->setStateGroup(
nullptr);
150 state->setStateGroup(_this);
156 return _this->d_func()->
states.size();
168 _this->d_func()->setCurrentStateInternal(
QString(),
true);
170 if (_this->d_func()->
states.at(
i))
171 _this->d_func()->
states.at(
i)->setStateGroup(
nullptr);
173 _this->d_func()->
states.clear();
179 auto *
d = self->d_func();
180 auto *oldState =
d->states.at(
index);
181 if (oldState !=
state) {
183 oldState->setStateGroup(
nullptr);
184 state->setStateGroup(self);
186 if (!oldState ||
d->currentState == oldState->name())
187 d->setCurrentStateInternal(
state->name(),
true);
194 if (
d->currentState ==
d->states.last()->name())
195 d->setCurrentStateInternal(
d->states.size() > 1 ?
d->states.first()->name() :
QString(),
true);
196 d->states.last()->setStateGroup(
nullptr);
197 d->states.removeLast();
280 return d->currentState;
286 if (
d->currentState ==
state)
289 d->setCurrentStateInternal(
state);
295 d->componentComplete =
false;
301 d->componentComplete =
true;
304 names.reserve(
d->states.size());
305 for (
int ii = 0; ii <
d->states.size(); ++ii) {
307 if (!
state->isNamed())
311 if (
names.contains(stateName)) {
312 qmlWarning(
state->parent()) <<
"Found duplicate state name: " << stateName;
318 if (
d->updateAutoState()) {
320 }
else if (!
d->currentState.isEmpty()) {
322 d->currentState.clear();
323 d->setCurrentStateInternal(cs,
true);
330bool QQuickStateGroup::updateAutoState()
333 return d->updateAutoState();
343 for (
int ii = 0; ii <
states.size(); ++ii) {
345 if (
state->isWhenKnown()) {
346 if (
state->isNamed()) {
347 bool whenValue =
state->when();
350 Q_ASSERT(!potentialWhenBinding.isUntypedPropertyBinding());
358 const auto boolType = QMetaType::fromType<bool>();
359 const bool isUndefined = !binding->
evaluate(&whenValue, boolType);
366 qCDebug(lcStates) <<
"Setting auto state due to expression";
368 q->setState(
state->name());
392 bool reversed =
false;
399 for (
int ii = 0; ii < 2; ++ii)
401 if (ii && (!
t->reversible() ||
405 const QString fromStateStr =
t->fromState();
406 const QString toStateStr =
t->toState();
409 for (
int jj = 0; jj < fromState.size(); ++jj)
410 fromState[jj] = fromState.at(jj).trimmed();
412 for (
int jj = 0; jj < toState.size(); ++jj)
413 toState[jj] = toState.at(jj).trimmed();
415 qSwap(fromState, toState);
420 else if (fromState.contains(
QStringView(asterisk)))
441 }
else if (tScore > score) {
464 qmlWarning(
q) <<
"Can't apply a state change as part of a state definition.";
471 if (lcStates().isDebugEnabled()) {
480 for (
int ii = 0; ii <
states.size(); ++ii) {
492 for (
int ii = 0; ii <
states.size(); ++ii) {
499 if (oldState ==
nullptr ||
newState ==
nullptr) {
509 newState->apply(transition, oldState);
516 for (
int i = 0;
i <
d->states.size(); ++
i) {
528 d->states.removeOne(
state);
531void QQuickStateGroup::stateAboutToComplete()
534 d->applyingState =
false;
540#include "moc_qquickstategroup_p.cpp"
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
virtual Kind kind() const =0
static QQmlAnyBinding ofProperty(const QQmlProperty &prop)
bool hasValidContext() const
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
The QQmlProperty class abstracts accessing properties on objects created from QML.
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 setStateGroup(QQuickStateGroup *)
QString fromState() const
\qmlproperty string QtQuick::Transition::from \qmlproperty string QtQuick::Transition::to
\macro QT_RESTRICTED_CAST_FROM_ASCII
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
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,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
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)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent