summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qabstracttransition.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-18 05:06:40 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-18 05:06:40 (GMT)
commit3769beacd9126b567f6a42e6c357a7eda004a602 (patch)
treeaa32717de1ccf0cae336e9682d81e5a9d7e845e5 /src/corelib/statemachine/qabstracttransition.cpp
parent0ed3e397eaebd1220d745c61cb3433998cbd9dd9 (diff)
parent9aba165d0ca970949bcc5fc590569ea58d992626 (diff)
downloadQt-3769beacd9126b567f6a42e6c357a7eda004a602.zip
Qt-3769beacd9126b567f6a42e6c357a7eda004a602.tar.gz
Qt-3769beacd9126b567f6a42e6c357a7eda004a602.tar.bz2
Merge branch 'kinetic-animations' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/corelib/animation/qanimationgroup.cpp src/corelib/animation/qvariantanimation.cpp src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'src/corelib/statemachine/qabstracttransition.cpp')
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp88
1 files changed, 32 insertions, 56 deletions
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index 1897aa6..a930581 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -125,9 +125,9 @@ QStateMachine *QAbstractTransitionPrivate::machine() const
return 0;
}
-bool QAbstractTransitionPrivate::callEventTest(QEvent *e) const
+bool QAbstractTransitionPrivate::callEventTest(QEvent *e)
{
- Q_Q(const QAbstractTransition);
+ Q_Q(QAbstractTransition);
return q->eventTest(e);
}
@@ -147,18 +147,8 @@ QState *QAbstractTransitionPrivate::sourceState() const
Constructs a new QAbstractTransition object with the given \a sourceState.
*/
QAbstractTransition::QAbstractTransition(QState *sourceState)
- : QObject(
-#ifndef QT_STATEMACHINE_SOLUTION
- *new QAbstractTransitionPrivate,
-#endif
- sourceState)
-#ifdef QT_STATEMACHINE_SOLUTION
- , d_ptr(new QAbstractTransitionPrivate)
-#endif
+ : QObject(*new QAbstractTransitionPrivate, sourceState)
{
-#ifdef QT_STATEMACHINE_SOLUTION
- d_ptr->q_ptr = this;
-#endif
}
/*!
@@ -167,20 +157,9 @@ QAbstractTransition::QAbstractTransition(QState *sourceState)
*/
QAbstractTransition::QAbstractTransition(const QList<QAbstractState*> &targets,
QState *sourceState)
- : QObject(
-#ifndef QT_STATEMACHINE_SOLUTION
- *new QAbstractTransitionPrivate,
-#endif
- sourceState)
-#ifdef QT_STATEMACHINE_SOLUTION
- , d_ptr(new QAbstractTransitionPrivate)
-#endif
+ : QObject(*new QAbstractTransitionPrivate, sourceState)
{
-#ifdef QT_STATEMACHINE_SOLUTION
- d_ptr->q_ptr = this;
-#endif
- Q_D(QAbstractTransition);
- d->targetStates = targets;
+ setTargetStates(targets);
}
/*!
@@ -188,18 +167,8 @@ QAbstractTransition::QAbstractTransition(const QList<QAbstractState*> &targets,
*/
QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
QState *parent)
- : QObject(
-#ifndef QT_STATEMACHINE_SOLUTION
- dd,
-#endif
- parent)
-#ifdef QT_STATEMACHINE_SOLUTION
- , d_ptr(&dd)
-#endif
+ : QObject(dd, parent)
{
-#ifdef QT_STATEMACHINE_SOLUTION
- d_ptr->q_ptr = this;
-#endif
}
/*!
@@ -208,20 +177,9 @@ QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
const QList<QAbstractState*> &targets,
QState *parent)
- : QObject(
-#ifndef QT_STATEMACHINE_SOLUTION
- dd,
-#endif
- parent)
-#ifdef QT_STATEMACHINE_SOLUTION
- , d_ptr(&dd)
-#endif
+ : QObject(dd, parent)
{
-#ifdef QT_STATEMACHINE_SOLUTION
- d_ptr->q_ptr = this;
-#endif
- Q_D(QAbstractTransition);
- d->targetStates = targets;
+ setTargetStates(targets);
}
/*!
@@ -229,9 +187,6 @@ QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
*/
QAbstractTransition::~QAbstractTransition()
{
-#ifdef QT_STATEMACHINE_SOLUTION
- delete d_ptr;
-#endif
}
/*!
@@ -265,7 +220,7 @@ void QAbstractTransition::setTargetState(QAbstractState* target)
if (!target)
d->targetStates.clear();
else
- d->targetStates = QList<QAbstractState*>() << target;
+ setTargetStates(QList<QAbstractState*>() << target);
}
/*!
@@ -275,7 +230,13 @@ void QAbstractTransition::setTargetState(QAbstractState* target)
QList<QAbstractState*> QAbstractTransition::targetStates() const
{
Q_D(const QAbstractTransition);
- return d->targetStates;
+ QList<QAbstractState*> result;
+ for (int i = 0; i < d->targetStates.size(); ++i) {
+ QAbstractState *target = d->targetStates.at(i);
+ if (target)
+ result.append(target);
+ }
+ return result;
}
/*!
@@ -284,7 +245,22 @@ QList<QAbstractState*> QAbstractTransition::targetStates() const
void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
{
Q_D(QAbstractTransition);
- d->targetStates = targets;
+
+ for (int i=0; i<targets.size(); ++i) {
+ QAbstractState *target = targets.at(i);
+ if (!target) {
+ qWarning("QAbstractTransition::setTargetStates: target state(s) cannot be null");
+ return;
+ }
+ if (target->machine() != 0 && target->machine()->rootState() == target) {
+ qWarning("QAbstractTransition::setTargetStates: root state cannot be target of transition");
+ return;
+ }
+ }
+
+ d->targetStates.clear();
+ for (int i = 0; i < targets.size(); ++i)
+ d->targetStates.append(targets.at(i));
}
/*!