getting rid of the ReverseStateChange enum in kxmlguiclient.h

Guillaume Laurent glaurent at telegraph-road.org
Fri Mar 23 10:20:39 GMT 2007


short version : this enum is used in a single method, and doesn't make the API 
any clearer compared to a bool.


Hi,

Longer version :

With the stabilisation of KDE4's API getting closer, I'd like to bring up an 
issue which was left dormant since the early KDE3 days for obvious reasons 
of, well, API stabilisation.

The aforementionned enum in kxmlguiclient is used when changing the 
internal 'state' of an app through the stateChanged() method. This is for 
maintaining the enabled/disabled state of actions (menu items, toolbar 
buttons). 

The sole purpose of this enum is to possibly specify that a state change is 
reversed, that is actions which are supposed to be enabled in this state will 
be disabled, and vice versa :

stateChanged(const QString &newstate,
             ReverseStateChange reverse = StateNoReverse)

I think this enum should be replaced by a simple bool. As it is, it doesn't 
make the API any clearer than a simple bool would (given the arg is 
named 'reverse').

Moreover, you very often want to call stateChange() through a signal/slot, but 
then having this enum is very unpractical because using it in the signal/slot 
definitions would mean that any object emitting such a signal would have to 
#include <kxmlguiclient.h> just for a single type, so you end up writing the 
signal/slot taking a bool instead, thus creating an inconsistency (albeit a 
minor one).

-- 
Guillaume.
http://telegraph-road.org




More information about the kde-core-devel mailing list