[PATCH] KFileDialog overwrite confirmation

Rafael Fernández López ereslibre at kde.org
Mon Jul 14 03:19:34 BST 2008


Hi,

Well, I know how it works ;), what I meant is if setConfirmOverride _needs_ to 
be virtual.

However, for a better portability I'd suggest for the future using an enum 
instead of an int. This way we could do something like:

// TODO KDE 5: Add this virtual methods and remove them from the hook
enum NewVirtualMethods {
	setConfirmOverride = 0
};

and you do something like:

void KAbstractFileWidget::setConfirmOverride(bool b)
{
	virtual_hook(setConfirmOverride, static_cast<void*>(&b));
}

void KFileWidget::virtual_hook(NewVirtualMethods method, void *data)
{
	switch(method) {
		case setConfirmOverride:
			bool *b = static_cast<bool*>(data);
			d->setConfirmOverride(b);
			break;
		default: // this depends !, virtual_hook is pure virtual
			 // here !!
			KAbstractFileWidget::virtual_hook(method, data);
	}
}

I have never thought on this pretty good technique for extending classes in a 
clean way. I really think we should do this more commonly.


Regards,
Rafael Fernández López.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080714/97ceb790/attachment.sig>


More information about the kde-core-devel mailing list