KSeparatorAction

Simon Hausmann hausmann at kde.org
Fri Dec 29 07:25:43 GMT 2006


On Friday 29 December 2006 00:16, Aaron J. Seigo wrote:
> On Thursday 28 December 2006 13:33, Simon Hausmann wrote:
> > The way I see it is that for one single line in application code we right
> > now provide an entire sub-class with an entire copy of the vtbl and moc
> > generated code. Is it really worth it?
>
> the only use case i can think of is possibly using it in a QList<QActions*>
> and then doing addActions() and that way include a separator.
>
> this seems to be how it is used in kdepim/kmail/kmmainwidget.cpp actually.
>
> this could probably be adjusted as well; there aren't too many uses of
> KSeparatorAction it seems... but answering the "what would replacing the
> uses of it in QList<QActions*> look like?" question is a prereq to removing
> it IMHO.

The following code I see for example in kmmainwidget.cpp:

       mFilterMenuActions.append( new KSeparatorAction() );

That would simply become

	QAction *a = new QAction(); // uh-oh, the old code had no parent
	a->setSeparator(true);
        mFilterMenuActions.append(a);

Ok, I stand corrected, it's two lines of code :). Re-using the previously 
created separator it'd become

QAction *a = mApplyFilterActionsMenu->menu()->addSeparator();
addedSeparator = !addedSeparator;
mFilterMenuActions.append(a);

... which is the same :).

I'm not sure where the comment in KSeparatorAction comes from that one cannot 
re-use a separator action :)


Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20061229/c5c7a66b/attachment.sig>


More information about the kde-core-devel mailing list