Make QSignalTransition take a pointer-to-const QObject
The obvious idea is that a connect() happens behind the scenes. As QObject::connect takes a pointer-to-const, QSignalTransition should do that as well. TODO: the API becomes asymmetric in that it takes a "const QObject *" but returns a "QObject *". Reasoning is needed. Change-Id: I18d0436e7036eee851fd36d5b8ccda4a4757938f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
parent
f052ee467d
commit
8b032fe423
@ -148,7 +148,7 @@ QSignalTransition::QSignalTransition(QState *sourceState)
|
||||
Constructs a new signal transition associated with the given \a signal of
|
||||
the given \a sender, and with the given \a sourceState.
|
||||
*/
|
||||
QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
|
||||
QSignalTransition::QSignalTransition(const QObject *sender, const char *signal,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QSignalTransitionPrivate, sourceState)
|
||||
{
|
||||
@ -171,13 +171,13 @@ QSignalTransition::~QSignalTransition()
|
||||
QObject *QSignalTransition::senderObject() const
|
||||
{
|
||||
Q_D(const QSignalTransition);
|
||||
return d->sender;
|
||||
return const_cast<QObject *>(d->sender);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a sender object associated with this signal transition.
|
||||
*/
|
||||
void QSignalTransition::setSenderObject(QObject *sender)
|
||||
void QSignalTransition::setSenderObject(const QObject *sender)
|
||||
{
|
||||
Q_D(QSignalTransition);
|
||||
if (sender == d->sender)
|
||||
|
@ -59,12 +59,12 @@ class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition
|
||||
Q_PROPERTY(QByteArray signal READ signal WRITE setSignal)
|
||||
public:
|
||||
QSignalTransition(QState *sourceState = 0);
|
||||
QSignalTransition(QObject *sender, const char *signal,
|
||||
QSignalTransition(const QObject *sender, const char *signal,
|
||||
QState *sourceState = 0);
|
||||
~QSignalTransition();
|
||||
|
||||
QObject *senderObject() const;
|
||||
void setSenderObject(QObject *sender);
|
||||
void setSenderObject(const QObject *sender);
|
||||
|
||||
QByteArray signal() const;
|
||||
void setSignal(const QByteArray &signal);
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
|
||||
virtual void callOnTransition(QEvent *e);
|
||||
|
||||
QObject *sender;
|
||||
const QObject *sender;
|
||||
QByteArray signal;
|
||||
int signalIndex;
|
||||
int originalSignalIndex;
|
||||
|
@ -348,7 +348,7 @@ void QState::addTransition(QAbstractTransition *transition)
|
||||
object, and returns the new QSignalTransition object. The transition has
|
||||
this state as the source, and the given \a target as the target state.
|
||||
*/
|
||||
QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
|
||||
QSignalTransition *QState::addTransition(const QObject *sender, const char *signal,
|
||||
QAbstractState *target)
|
||||
{
|
||||
if (!sender) {
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
void setErrorState(QAbstractState *state);
|
||||
|
||||
void addTransition(QAbstractTransition *transition);
|
||||
QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
|
||||
QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target);
|
||||
QAbstractTransition *addTransition(QAbstractState *target);
|
||||
void removeTransition(QAbstractTransition *transition);
|
||||
QList<QAbstractTransition*> transitions() const;
|
||||
|
@ -1739,7 +1739,7 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio
|
||||
Q_Q(QStateMachine);
|
||||
if (QSignalTransitionPrivate::get(transition)->signalIndex != -1)
|
||||
return; // already registered
|
||||
QObject *sender = QSignalTransitionPrivate::get(transition)->sender;
|
||||
const QObject *sender = QSignalTransitionPrivate::get(transition)->sender;
|
||||
if (!sender)
|
||||
return;
|
||||
QByteArray signal = QSignalTransitionPrivate::get(transition)->signal;
|
||||
|
Loading…
Reference in New Issue
Block a user