[kdeui] return type of KActionCollection::actionsOfType()
Michel Hermier
michel.hermier at gmail.com
Sat Nov 25 00:05:22 GMT 2006
Hi,
Jarosław Staniek wrote:
>
> 1. A question about:
>
> template<class T>
> KAction* KActionCollection::actionsOfType( const QString & name )const
>
> Logic and the docs say "Returns: A list of all KActions in the
> collection which match the parameters" but it's return type is
> KAction* instead of QList<KAction*> ...
>
> How does it even compile?
Maybe because it's a template class and it's not used.
>
> 2. actionsOfType() could return QList<T*>.
>
> Reasoning: if I am looking for a given type, I'll be most probably try
> to use it's methods, e.g. KSelectAction::comboWidth(). SO why should I
> cast again?
>
Sounds logical, but introduce a problem in implementation.
QList<T*> actionsOfTypeInternal( const QString& name, const QMetaObject&
mo ) const
have to be a template and therefore be included in the .h, which is not
acceptable I think, and also remove the interest of having the internal
methods.
So the the valid choice would be to cast the returned list to a new list.
Looking at this code make me wonder why ((T)0)->staticMetaObject was
used instead of T::staticMetaObject ?
Michel
More information about the kde-core-devel
mailing list