change bool to enum : KUrl
David Faure
faure at kde.org
Tue May 2 18:20:26 BST 2006
On Tuesday 02 May 2006 16:31, Olivier Goffart wrote:
> Le Mardi 2 Mai 2006 15:49, David Faure a écrit :
> > On Tuesday 02 May 2006 00:44, Olivier Goffart wrote:
> > > + enum CleanPathOption
> > > + {
> > > + /**
> > > + * if set, occurences of consecutive directory separators
> > > + * (e.g. /foo//bar) are cleaned up as well. (set by default)
> > > + */
> > > + CleanDirSeparator = 0x01,
> > > +
> > > + /**
> > > + * The opposite of CleanDirSeparator.
> > > + */
> > > + LeaveDirSeparator = 0x00
> > > + };
> > > +
> > > + Q_DECLARE_FLAGS(CleanPathOptions,CleanPathOption)
> >
> > This one is not really a "flag" (as in "one or the other or both"), is it?
> > It seems to be a standard enum instead; except that the type safety that
> > QFlag gives is nice, of course. Does Qt provide a way to declare a
> > "typesafe enum"?
>
> AFAIK, C++ enum are already type safe, even more than QFlags which accept 0
> (or false)
Hmm, that's right, taking CleanPathOption (no s) in the method would do the job.
> I Made a QFlags here to be able to eventually estand it later.
"estand"?
I don't understand. My point is that LeaveDirSeparator=0 doesn't make a good
entry in a QFlag, because it's not scalable. If you add a new option like
MakeCoffee, the name for value 0 should then become LeaveDirSeparatorAndMakeNoCoffee?
I guess in other similar situations we simply named the value for 0 something like
"Defaults".
> > At least this line is wrong:
> > + Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::CleanPathOptions);
> > since LeaveDirSeparator | CleanDirSeparator would make no sense.
IMHO we should at least comment out this until there are are more flags, which would
then need the '|' operator to be useful.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel
mailing list