Remove QSignalMapper::mappedWidget()

mappedObject() can do exactly the same thing, there's no need for a
mappedWidget() signal as well

This removes a reverse dependency between Qt Widgets and Qt Core where
QWidget pointers are being used inside Qt Core.

[ChangeLog][QtCore] Removed QSignalMapper::mappedWidget. Connect to
mappedObject instead, and use qobject_cast<QWidget *> to handle Widgets.

Change-Id: I60618a34dd94575e993bd6d8a2cead95cfd71d55
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Lars Knoll 2020-03-19 13:30:35 +01:00
parent 53f8f23369
commit 874c6b00dd
2 changed files with 2 additions and 43 deletions

View File

@ -68,13 +68,11 @@ public:
{
emitMappedValue(sender, &QSignalMapper::mappedInt, intHash);
emitMappedValue(sender, &QSignalMapper::mappedString, stringHash);
emitMappedValue(sender, &QSignalMapper::mappedWidget, widgetHash);
emitMappedValue(sender, &QSignalMapper::mappedObject, objectHash);
}
QHash<QObject *, int> intHash;
QHash<QObject *, QString> stringHash;
QHash<QObject *, QWidget*> widgetHash;
QHash<QObject *, QObject*> objectHash;
};
@ -95,8 +93,8 @@ public:
The class supports the mapping of particular strings, integers,
objects and widgets with particular objects using setMapping().
The objects' signals can then be connected to the map() slot which
will emit a signal (it could be mappedInt(), mappedString(),
mappedWidget() and mappedObject()) with a value associated with
will emit a signal (it could be mappedInt(), mappedString()
and mappedObject()) with a value associated with
the original signalling object. Mappings can be removed later using
removeMappings().
@ -182,19 +180,6 @@ void QSignalMapper::setMapping(QObject *sender, const QString &text)
connect(sender, SIGNAL(destroyed()), this, SLOT(_q_senderDestroyed()));
}
/*!
Adds a mapping so that when map() is signalled from the \a sender,
the signal mappedWidget(\a widget ) is emitted.
There may be at most one widget for each sender.
*/
void QSignalMapper::setMapping(QObject *sender, QWidget *widget)
{
Q_D(QSignalMapper);
d->widgetHash.insert(sender, widget);
connect(sender, SIGNAL(destroyed()), this, SLOT(_q_senderDestroyed()));
}
/*!
Adds a mapping so that when map() is signalled from the \a sender,
the signal mappedObject(\a object ) is emitted.
@ -228,17 +213,6 @@ QObject *QSignalMapper::mapping(const QString &id) const
return d->stringHash.key(id);
}
/*!
\overload mapping()
Returns the sender QObject that is associated with the \a widget.
*/
QObject *QSignalMapper::mapping(QWidget *widget) const
{
Q_D(const QSignalMapper);
return d->widgetHash.key(widget);
}
/*!
\overload mapping()
@ -264,7 +238,6 @@ void QSignalMapper::removeMappings(QObject *sender)
d->intHash.remove(sender);
d->stringHash.remove(sender);
d->widgetHash.remove(sender);
d->objectHash.remove(sender);
}
@ -303,17 +276,6 @@ void QSignalMapper::map(QObject *sender)
\sa setMapping()
*/
/*!
\fn void QSignalMapper::mappedWidget(QWidget *widget)
\since 5.15
This signal is emitted when map() is signalled from an object that
has a widget mapping set. The object's mapped widget is passed in
\a widget.
\sa setMapping()
*/
/*!
\fn void QSignalMapper::mappedObject(QObject *object)
\since 5.15

View File

@ -56,19 +56,16 @@ public:
void setMapping(QObject *sender, int id);
void setMapping(QObject *sender, const QString &text);
void setMapping(QObject *sender, QWidget *widget);
void setMapping(QObject *sender, QObject *object);
void removeMappings(QObject *sender);
QObject *mapping(int id) const;
QObject *mapping(const QString &text) const;
QObject *mapping(QWidget *widget) const;
QObject *mapping(QObject *object) const;
Q_SIGNALS:
void mappedInt(int);
void mappedString(const QString &);
void mappedWidget(QWidget *);
void mappedObject(QObject *);
public Q_SLOTS: