42 #include "private/qdeclarativestategroup_p.h" 44 #include "private/qdeclarativetransition_p.h" 45 #include "private/qdeclarativestate_p_p.h" 50 #include <QtCore/qstringbuilder.h> 51 #include <QtCore/qdebug.h> 53 #include <private/qobject_p.h> 135 for (
int i = 0; i <
d->states.count(); ++i)
136 d->states.at(i)->setStateGroup(0);
196 return _this->d_func()->
states.
at(index);
202 _this->d_func()->setCurrentStateInternal(
QString(),
true);
203 for (
int i = 0; i < _this->d_func()->
states.
count(); ++i) {
204 _this->d_func()->
states.
at(i)->setStateGroup(0);
295 return d->currentState;
301 if (
d->currentState == state)
304 d->setCurrentStateInternal(state);
318 for (
int ii = 0; ii <
d->states.count(); ++ii) {
324 if (
d->updateAutoState()) {
326 }
else if (!
d->currentState.isEmpty()) {
328 d->currentState.clear();
329 d->setCurrentStateInternal(cs,
true);
339 return d->updateAutoState();
354 if (stateChangeDebug())
355 qWarning() <<
"Setting auto state due to:" 357 if (currentState != state->
name()) {
358 q->setState(state->
name());
363 }
else if (state->
name() == currentState) {
370 bool rv = !currentState.
isEmpty();
382 bool reversed =
false;
387 for (
int ii = 0; ii < 2; ++ii)
399 qSwap(fromState, toState);
424 }
else if (tScore > score) {
442 currentState =
state;
447 qmlInfo(q) <<
"Can't apply a state change as part of a state definition.";
451 applyingState =
true;
453 QDeclarativeTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state);
454 if (stateChangeDebug()) {
455 qWarning() <<
this <<
"Changing state. From" << currentState <<
". To" <<
state;
462 if (!currentState.isEmpty()) {
471 currentState =
state;
472 emit q->stateChanged(currentState);
482 if (oldState == 0 || newState == 0) {
484 if (!oldState) oldState = nullState;
485 if (!newState) newState = nullState;
488 newState->
apply(q, transition, oldState);
489 applyingState =
false;
497 for (
int i = 0; i <
d->states.count(); ++i) {
509 d->states.removeOne(state);
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool updateAutoState()
Returns true if the state was changed, otherwise false.
#define QT_END_NAMESPACE
This macro expands to.
QDeclarativeParserStatus ** d
void setCurrentStateInternal(const QString &state, bool=false)
static void clear_states(QDeclarativeListProperty< QDeclarativeState > *list)
static int count_state(QDeclarativeListProperty< QDeclarativeState > *list)
QList< QDeclarativeState * > states() const
QDeclarativeListProperty< QDeclarativeTransition > transitions
virtual void componentComplete()
Invoked after the root component that caused this instantiation has completed construction.
static void append_state(QDeclarativeListProperty< QDeclarativeState > *list, QDeclarativeState *state)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
QVariant evaluate(bool *valueIsUndefined=0)
Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expre...
int count(const T &t) const
Returns the number of occurrences of value in the list.
static void append_transition(QDeclarativeListProperty< QDeclarativeTransition > *list, QDeclarativeTransition *state)
The QString class provides a Unicode character string.
QDeclarativeState * findState(const QString &name) const
The QObject class is the base class of all Qt objects.
QDeclarativeListProperty< QDeclarativeState > statesProperty()
static QObjectPrivate * get(QObject *o)
static int count_transitions(QDeclarativeListProperty< QDeclarativeTransition > *list)
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
static void clear_transitions(QDeclarativeListProperty< QDeclarativeTransition > *list)
QDeclarativeBinding * when
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual ~QDeclarativeStateGroup()
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
QString fromState() const
void setState(const QString &)
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QDeclarativeStateGroupPrivate()
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
friend class QDeclarativeState
void setName(const QString &)
void removeState(QDeclarativeState *state)
void qSwap(T &value1, T &value2)
QDeclarativeListProperty< QDeclarativeTransition > transitionsProperty()
#define Q_DECLARE_PUBLIC(Class)
QList< QDeclarativeTransition * > transitions
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QList< QDeclarativeState * > states
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG)
virtual QString expression() const
static QDeclarativeTransition * at_transition(QDeclarativeListProperty< QDeclarativeTransition > *list, int index)
void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert)
QDeclarativeState * nullState
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
QDeclarativeListProperty< QDeclarativeState > states
QDeclarativeInfo qmlInfo(const QObject *me)
static QDeclarativeState * at_state(QDeclarativeListProperty< QDeclarativeState > *list, int index)
virtual void classBegin()
Invoked after class creation, but before any properties have been set.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QDeclarativeStateGroup(QObject *=0)
The QList class is a template class that provides lists.
QDeclarativeTransition * findTransition(const QString &from, const QString &to)
void setStateGroup(QDeclarativeStateGroup *)