proposed KAction/KActionCollection API changes
ervin at kde.org
Wed Jan 3 11:23:24 GMT 2007
Le Mardi 2 Janvier 2007 23:16, Olivier Goffart a écrit :
> Anyway, in general, we create a lot of KAction in the same time.
> So i think it was a benefit to create one action in one line. I find it
Well, I think we agree to disagree here. :-)
> Also, addAction sometimes create a new object, and sometimes doesn't. maybe
> the addAction() which create a new KAction should be newAction()
Actually, at the start it was named createAction(), we chose to rename it
addAction() for consistency with the Qt API which name this kind of methods
addFoo() when they "create+insert".
That said, Simon do you think we should have the following?
QAction *KActionCollection::addAction(const QString &name);
KActionCollection::insertAction(const QString &name, QAction *action);
(Currently both are named addAction())
> actionCollection()->newAction("view_reload", i18n("&Reload"),
> KIcon("reload"), CTRL+Key_F5, this, SLOT(reload()) );
> actionCollection()->newAction("history_back", i18n("&Back"),
> KIcon("back"), ALT+Key_Left, this, SLOT(back()) );
> actionCollection()->newAction("history_next", i18n("&Next"),
> KIcon("next"), ALT+Key_Right, this, SLOT(next()) );
> This look beautiful, is less verbose, but isn't more hard to read (i think)
That's where I disagree, for someone knowing by heart all the methods this
kind of table might help. Otherwise you'll probably wonder about the role of
each parameter. Hence why IMO it's harder to maintain and read.
> also, the text+icon could be a KGuiItem ?
In my experience there's no big need for this, KGuiItem are mostly used for
standard GUI element and for actions we already have KStandardAction factory
Kévin 'ervin' Ottens, http://ervin.ipsquad.net
"Ni le maître sans disciple, Ni le disciple sans maître,
Ne font reculer l'ignorance."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the kde-core-devel