Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QDeclarativeStateGroupPrivate Class Reference
Inheritance diagram for QDeclarativeStateGroupPrivate:
QObjectPrivate QObjectData

Public Functions

QDeclarativeTransitionfindTransition (const QString &from, const QString &to)
 
 QDeclarativeStateGroupPrivate ()
 
void setCurrentStateInternal (const QString &state, bool=false)
 
bool updateAutoState ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static void append_state (QDeclarativeListProperty< QDeclarativeState > *list, QDeclarativeState *state)
 
static void append_transition (QDeclarativeListProperty< QDeclarativeTransition > *list, QDeclarativeTransition *state)
 
static QDeclarativeStateat_state (QDeclarativeListProperty< QDeclarativeState > *list, int index)
 
static QDeclarativeTransitionat_transition (QDeclarativeListProperty< QDeclarativeTransition > *list, int index)
 
static void clear_states (QDeclarativeListProperty< QDeclarativeState > *list)
 
static void clear_transitions (QDeclarativeListProperty< QDeclarativeTransition > *list)
 
static int count_state (QDeclarativeListProperty< QDeclarativeState > *list)
 
static int count_transitions (QDeclarativeListProperty< QDeclarativeTransition > *list)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool applyingState
 
bool componentComplete
 
QString currentState
 
bool ignoreTrans
 
QDeclarativeStatenullState
 
QList< QDeclarativeState * > states
 
QList< QDeclarativeTransition * > transitions
 
int unnamedCount
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 60 of file qdeclarativestategroup.cpp.

Constructors and Destructors

◆ QDeclarativeStateGroupPrivate()

QDeclarativeStateGroupPrivate::QDeclarativeStateGroupPrivate ( )
inline

Functions

◆ append_state()

void QDeclarativeStateGroupPrivate::append_state ( QDeclarativeListProperty< QDeclarativeState > *  list,
QDeclarativeState state 
)
static

Definition at line 177 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::statesProperty().

178 {
179  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
180  if (state) {
181  _this->d_func()->states.append(state);
182  state->setStateGroup(_this);
183  }
184 
185 }
QDeclarativeListProperty< QDeclarativeState > states
void setStateGroup(QDeclarativeStateGroup *)

◆ append_transition()

void QDeclarativeStateGroupPrivate::append_transition ( QDeclarativeListProperty< QDeclarativeTransition > *  list,
QDeclarativeTransition state 
)
static

Definition at line 241 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::transitionsProperty().

242 {
243  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
244  if (trans)
245  _this->d_func()->transitions.append(trans);
246 }
QDeclarativeListProperty< QDeclarativeTransition > transitions

◆ at_state()

QDeclarativeState * QDeclarativeStateGroupPrivate::at_state ( QDeclarativeListProperty< QDeclarativeState > *  list,
int  index 
)
static

Definition at line 193 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::statesProperty().

194 {
195  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
196  return _this->d_func()->states.at(index);
197 }
quint16 index
QDeclarativeListProperty< QDeclarativeState > states

◆ at_transition()

QDeclarativeTransition * QDeclarativeStateGroupPrivate::at_transition ( QDeclarativeListProperty< QDeclarativeTransition > *  list,
int  index 
)
static

Definition at line 254 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::transitionsProperty().

255 {
256  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
257  return _this->d_func()->transitions.at(index);
258 }
QDeclarativeListProperty< QDeclarativeTransition > transitions
quint16 index

◆ clear_states()

void QDeclarativeStateGroupPrivate::clear_states ( QDeclarativeListProperty< QDeclarativeState > *  list)
static

Definition at line 199 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::statesProperty().

200 {
201  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
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);
205  }
206  _this->d_func()->states.clear();
207 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QDeclarativeListProperty< QDeclarativeState > states

◆ clear_transitions()

void QDeclarativeStateGroupPrivate::clear_transitions ( QDeclarativeListProperty< QDeclarativeTransition > *  list)
static

Definition at line 260 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::transitionsProperty().

261 {
262  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
263  _this->d_func()->transitions.clear();
264 }
QDeclarativeListProperty< QDeclarativeTransition > transitions

◆ count_state()

int QDeclarativeStateGroupPrivate::count_state ( QDeclarativeListProperty< QDeclarativeState > *  list)
static

Definition at line 187 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::statesProperty().

188 {
189  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
190  return _this->d_func()->states.count();
191 }
QDeclarativeListProperty< QDeclarativeState > states

◆ count_transitions()

int QDeclarativeStateGroupPrivate::count_transitions ( QDeclarativeListProperty< QDeclarativeTransition > *  list)
static

Definition at line 248 of file qdeclarativestategroup.cpp.

Referenced by QDeclarativeStateGroup::transitionsProperty().

249 {
250  QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
251  return _this->d_func()->transitions.count();
252 }
QDeclarativeListProperty< QDeclarativeTransition > transitions

◆ findTransition()

QDeclarativeTransition * QDeclarativeStateGroupPrivate::findTransition ( const QString from,
const QString to 
)

Definition at line 378 of file qdeclarativestategroup.cpp.

379 {
380  QDeclarativeTransition *highest = 0;
381  int score = 0;
382  bool reversed = false;
383  bool done = false;
384 
385  for (int ii = 0; !done && ii < transitions.count(); ++ii) {
387  for (int ii = 0; ii < 2; ++ii)
388  {
389  if (ii && (!t->reversible() ||
390  (t->fromState() == QLatin1String("*") &&
391  t->toState() == QLatin1String("*"))))
392  break;
393  QStringList fromState;
394  QStringList toState;
395 
396  fromState = t->fromState().split(QLatin1Char(','));
397  toState = t->toState().split(QLatin1Char(','));
398  if (ii == 1)
399  qSwap(fromState, toState);
400  int tScore = 0;
401  if (fromState.contains(from))
402  tScore += 2;
403  else if (fromState.contains(QLatin1String("*")))
404  tScore += 1;
405  else
406  continue;
407 
408  if (toState.contains(to))
409  tScore += 2;
410  else if (toState.contains(QLatin1String("*")))
411  tScore += 1;
412  else
413  continue;
414 
415  if (ii == 1)
416  reversed = true;
417  else
418  reversed = false;
419 
420  if (tScore == 4) {
421  highest = t;
422  done = true;
423  break;
424  } else if (tScore > score) {
425  score = tScore;
426  highest = t;
427  }
428  }
429  }
430 
431  if (highest)
432  highest->setReversed(reversed);
433 
434  return highest;
435 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
QList< QDeclarativeTransition * > transitions
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...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ setCurrentStateInternal()

void QDeclarativeStateGroupPrivate::setCurrentStateInternal ( const QString state,
bool  ignoreTrans = false 
)

Definition at line 437 of file qdeclarativestategroup.cpp.

439 {
441  if (!componentComplete) {
442  currentState = state;
443  return;
444  }
445 
446  if (applyingState) {
447  qmlInfo(q) << "Can't apply a state change as part of a state definition.";
448  return;
449  }
450 
451  applyingState = true;
452 
454  if (stateChangeDebug()) {
455  qWarning() << this << "Changing state. From" << currentState << ". To" << state;
456  if (transition)
457  qWarning() << " using transition" << transition->fromState()
458  << transition->toState();
459  }
460 
461  QDeclarativeState *oldState = 0;
462  if (!currentState.isEmpty()) {
463  for (int ii = 0; ii < states.count(); ++ii) {
464  if (states.at(ii)->name() == currentState) {
465  oldState = states.at(ii);
466  break;
467  }
468  }
469  }
470 
471  currentState = state;
472  emit q->stateChanged(currentState);
473 
474  QDeclarativeState *newState = 0;
475  for (int ii = 0; ii < states.count(); ++ii) {
476  if (states.at(ii)->name() == currentState) {
477  newState = states.at(ii);
478  break;
479  }
480  }
481 
482  if (oldState == 0 || newState == 0) {
484  if (!oldState) oldState = nullState;
485  if (!newState) newState = nullState;
486  }
487 
488  newState->apply(q, transition, oldState);
489  applyingState = false;
490  if (!transition)
491  static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(newState))->complete();
492 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QList< QDeclarativeState * > states
void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert)
QDeclarativeInfo qmlInfo(const QObject *me)
QDeclarativeTransition * findTransition(const QString &from, const QString &to)

◆ updateAutoState()

bool QDeclarativeStateGroupPrivate::updateAutoState ( )

Definition at line 342 of file qdeclarativestategroup.cpp.

343 {
345  if (!componentComplete)
346  return false;
347 
348  bool revert = false;
349  for (int ii = 0; ii < states.count(); ++ii) {
350  QDeclarativeState *state = states.at(ii);
351  if (state->isWhenKnown()) {
352  if (state->isNamed()) {
353  if (state->when() && state->when()->evaluate().toBool()) {
354  if (stateChangeDebug())
355  qWarning() << "Setting auto state due to:"
356  << state->when()->expression();
357  if (currentState != state->name()) {
358  q->setState(state->name());
359  return true;
360  } else {
361  return false;
362  }
363  } else if (state->name() == currentState) {
364  revert = true;
365  }
366  }
367  }
368  }
369  if (revert) {
370  bool rv = !currentState.isEmpty();
371  q->setState(QString());
372  return rv;
373  } else {
374  return false;
375  }
376 }
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
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.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeBinding * when
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
QList< QDeclarativeState * > states
virtual QString expression() const

Properties

◆ applyingState

bool QDeclarativeStateGroupPrivate::applyingState

Definition at line 86 of file qdeclarativestategroup.cpp.

◆ componentComplete

bool QDeclarativeStateGroupPrivate::componentComplete

Definition at line 84 of file qdeclarativestategroup.cpp.

◆ currentState

QString QDeclarativeStateGroupPrivate::currentState

Definition at line 68 of file qdeclarativestategroup.cpp.

◆ ignoreTrans

bool QDeclarativeStateGroupPrivate::ignoreTrans

Definition at line 85 of file qdeclarativestategroup.cpp.

◆ nullState

QDeclarativeState* QDeclarativeStateGroupPrivate::nullState

Definition at line 69 of file qdeclarativestategroup.cpp.

◆ states

QList<QDeclarativeState *> QDeclarativeStateGroupPrivate::states

Definition at line 81 of file qdeclarativestategroup.cpp.

◆ transitions

QList<QDeclarativeTransition *> QDeclarativeStateGroupPrivate::transitions

Definition at line 82 of file qdeclarativestategroup.cpp.

◆ unnamedCount

int QDeclarativeStateGroupPrivate::unnamedCount

Definition at line 87 of file qdeclarativestategroup.cpp.


The documentation for this class was generated from the following file: